Skip to content

Commit d23b1df

Browse files
gkelloggdavidlehn
authored andcommitted
Suggested style improvements.
1 parent e9f70ba commit d23b1df

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

lib/compact.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ api.compact = ({
143143

144144
// process element keys in order
145145
const keys = Object.keys(element).sort();
146-
for(let expandedProperty of keys) {
146+
for(const expandedProperty of keys) {
147147
const expandedValue = element[expandedProperty];
148148

149149
// compact @id and @type(s)
@@ -160,7 +160,7 @@ api.compact = ({
160160
} else {
161161
// expanded value must be a @type array
162162
compactedValue = [];
163-
for(let expandedIri of expandedValue) {
163+
for(const expandedIri of expandedValue) {
164164
const compactedType = api.compactIri(
165165
{activeCtx, iri: expandedIri, relativeTo: {vocab: true}})
166166

@@ -193,7 +193,7 @@ api.compact = ({
193193
});
194194

195195
// handle double-reversed properties
196-
for(let compactedProperty in compactedValue) {
196+
for(const compactedProperty in compactedValue) {
197197
if(activeCtx.mappings[compactedProperty] &&
198198
activeCtx.mappings[compactedProperty].reverse) {
199199
const value = compactedValue[compactedProperty];
@@ -270,7 +270,7 @@ api.compact = ({
270270
}
271271

272272
// recusively process array values
273-
for(let expandedItem of expandedValue) {
273+
for(const expandedItem of expandedValue) {
274274
// compact property and get container type
275275
const itemActiveProperty = api.compactIri({
276276
activeCtx,
@@ -844,7 +844,7 @@ api.removePreserve = (ctx, input, options) => {
844844
}
845845

846846
// recurse through properties
847-
for(let prop in input) {
847+
for(const prop in input) {
848848
let result = api.removePreserve(ctx, input[prop], options);
849849
const container = _getContextValue(ctx, prop, '@container') || [];
850850
if(options.compactArrays && _isArray(result) && result.length === 1 &&
@@ -939,4 +939,4 @@ function _checkNestProperty(activeCtx, nestProperty) {
939939
'JSON-LD compact error; nested property must have an @nest value resolving to @nest.',
940940
'jsonld.SyntaxError', {code: 'invalid @nest value'});
941941
}
942-
}
942+
}

lib/context.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ api.process = ({activeCtx, localCtx, options}) => {
172172
}
173173

174174
// process all other keys
175-
for(let key in ctx) {
175+
for(const key in ctx) {
176176
api.createTermDefinition(rval, ctx, key, defined);
177177
}
178178

@@ -266,7 +266,7 @@ api.createTermDefinition = (activeCtx, localCtx, term, defined) => {
266266
validKeys.push('@context', '@nest', '@prefix');
267267
}
268268

269-
for(let kw in value) {
269+
for(const kw in value) {
270270
if(!validKeys.includes(kw)) {
271271
throw new JsonLdError(
272272
'Invalid JSON-LD syntax; a term definition must not contain ' + kw,
@@ -730,7 +730,7 @@ api.getInitialContext = (options) => {
730730
}
731731

732732
// build fast CURIE map
733-
for(let key in fastCurieMap) {
733+
for(const key in fastCurieMap) {
734734
_buildIriMap(fastCurieMap, key, 1);
735735
}
736736

@@ -765,7 +765,7 @@ api.getInitialContext = (options) => {
765765
}
766766
}
767767

768-
for(let key in next) {
768+
for(const key in next) {
769769
if(key === '') {
770770
continue;
771771
}
@@ -1042,7 +1042,7 @@ function _findContextUrls(input, urls, replace, base) {
10421042
}
10431043

10441044
// input is an object
1045-
for(let key in input) {
1045+
for(const key in input) {
10461046
if(key !== '@context') {
10471047
_findContextUrls(input[key], urls, replace, base);
10481048
continue;
@@ -1077,7 +1077,7 @@ function _findContextUrls(input, urls, replace, base) {
10771077
}
10781078
} else {
10791079
// look for scoped context
1080-
for(let key in _ctx) {
1080+
for(const key in _ctx) {
10811081
if(_isObject(_ctx[key])) {
10821082
_findContextUrls(_ctx[key], urls, replace, base);
10831083
}
@@ -1098,7 +1098,7 @@ function _findContextUrls(input, urls, replace, base) {
10981098
}
10991099
} else {
11001100
// look for scoped context
1101-
for(let key in ctx) {
1101+
for(const key in ctx) {
11021102
if(_isObject(ctx[key])) {
11031103
_findContextUrls(ctx[key], urls, replace, base);
11041104
}

lib/expand.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ api.expand = ({
161161
}
162162
}
163163

164-
165164
// expand the active property
166165
const expandedActiveProperty = _expandIri(
167166
activeCtx, activeProperty, {vocab: true});
@@ -455,7 +454,7 @@ function _expandObject({
455454
});
456455
// properties double-reversed
457456
if('@reverse' in expandedValue) {
458-
for(let property in expandedValue['@reverse']) {
457+
for(const property in expandedValue['@reverse']) {
459458
_addValue(
460459
expandedParent, property, expandedValue['@reverse'][property],
461460
{propertyIsArray: true});
@@ -465,7 +464,7 @@ function _expandObject({
465464
// FIXME: can this be merged with code below to simplify?
466465
// merge in all reversed properties
467466
let reverseMap = expandedParent['@reverse'] || null;
468-
for(let property in expandedValue) {
467+
for(const property in expandedValue) {
469468
if(property === '@reverse') {
470469
continue;
471470
}
@@ -644,9 +643,9 @@ function _expandObject({
644643
}
645644

646645
// expand each nested key
647-
for(let key of nests) {
646+
for(const key of nests) {
648647
const nestedValues = _isArray(element[key]) ? element[key] : [element[key]];
649-
for(let nv of nestedValues) {
648+
for(const nv of nestedValues) {
650649
if(!_isObject(nv) ||
651650
Object.keys(nv).some(k => _expandIri(activeCtx, k, {vocab: true}) === '@value')) {
652651
throw new JsonLdError(
@@ -740,13 +739,13 @@ function _expandValue({activeCtx, activeProperty, value}) {
740739
function _expandLanguageMap(activeCtx, languageMap) {
741740
const rval = [];
742741
const keys = Object.keys(languageMap).sort();
743-
for(let key of keys) {
742+
for(const key of keys) {
744743
const expandedKey = _expandIri(activeCtx, key, {vocab: true})
745744
let val = languageMap[key];
746745
if(!_isArray(val)) {
747746
val = [val];
748747
}
749-
for(let item of val) {
748+
for(const item of val) {
750749
if(item === null) {
751750
// null values are allowed (8.5) but ignored (3.1)
752751
continue;

0 commit comments

Comments
 (0)