Skip to content

Commit ad6079c

Browse files
Style conformance.
1 parent 633fe5a commit ad6079c

File tree

5 files changed

+31
-25
lines changed

5 files changed

+31
-25
lines changed

cycle.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
// cycle.js
2-
// 2011-01-18
2+
// 2011-02-23
33

4-
/*jslint forin: true, evil: true */
4+
/*jslint evil: true, regexp: false */
55

66
/*members $ref, apply, call, decycle, hasOwnProperty, length, prototype, push,
77
retrocycle, stringify, test, toString
88
*/
99

1010
if (typeof JSON.decycle !== 'function') {
1111
JSON.decycle = function decycle(object) {
12+
"use strict";
1213

1314
// Make a deep copy of an object or array, assuring that there is at most
1415
// one instance of each object or array in the resulting structure. The
@@ -74,7 +75,7 @@ if (typeof JSON.decycle !== 'function') {
7475

7576
nu = {};
7677
for (name in value) {
77-
if (Object.hasOwnProperty.call(value, name)) {
78+
if (Object.prototype.hasOwnProperty.call(value, name)) {
7879
nu[name] = derez(value[name],
7980
path + '[' + JSON.stringify(name) + ']');
8081
}
@@ -93,6 +94,7 @@ if (typeof JSON.decycle !== 'function') {
9394

9495
if (typeof JSON.retrocycle !== 'function') {
9596
JSON.retrocycle = function retrocycle($) {
97+
"use strict";
9698

9799
// Restore an object that was reduced by decycle. Members whose values are
98100
// objects of the form
@@ -140,13 +142,15 @@ if (typeof JSON.retrocycle !== 'function') {
140142
}
141143
} else {
142144
for (name in value) {
143-
item = value[name];
144-
if (item && typeof item === 'object') {
145-
path = item.$ref;
146-
if (typeof path === 'string' && px.test(path)) {
147-
value[name] = eval(path);
148-
} else {
149-
rez(item);
145+
if (typeof value[name] === 'object') {
146+
item = value[name];
147+
if (item) {
148+
path = item.$ref;
149+
if (typeof path === 'string' && px.test(path)) {
150+
value[name] = eval(path);
151+
} else {
152+
rez(item);
153+
}
150154
}
151155
}
152156
}

json.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
json.js
3-
2011-01-18
3+
2011-02-23
44
55
Public Domain
66
@@ -365,7 +365,7 @@ if (!JSON) {
365365
// Otherwise, iterate through all of the keys in the object.
366366

367367
for (k in value) {
368-
if (Object.hasOwnProperty.call(value, k)) {
368+
if (Object.prototype.hasOwnProperty.call(value, k)) {
369369
v = str(k, value);
370370
if (v) {
371371
partial.push(quote(k) + (gap ? ': ' : ':') + v);
@@ -450,7 +450,7 @@ if (!JSON) {
450450
var k, v, value = holder[key];
451451
if (value && typeof value === 'object') {
452452
for (k in value) {
453-
if (Object.hasOwnProperty.call(value, k)) {
453+
if (Object.prototype.hasOwnProperty.call(value, k)) {
454454
v = walk(value, k);
455455
if (v !== undefined) {
456456
value[k] = v;

json2.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
http://www.JSON.org/json2.js
3-
2011-01-18
3+
2011-02-23
44
55
Public Domain.
66
@@ -315,8 +315,8 @@ if (!JSON) {
315315
if (rep && typeof rep === 'object') {
316316
length = rep.length;
317317
for (i = 0; i < length; i += 1) {
318-
k = rep[i];
319-
if (typeof k === 'string') {
318+
if (typeof rep[i] === 'string') {
319+
k = rep[i];
320320
v = str(k, value);
321321
if (v) {
322322
partial.push(quote(k) + (gap ? ': ' : ':') + v);
@@ -328,7 +328,7 @@ if (!JSON) {
328328
// Otherwise, iterate through all of the keys in the object.
329329

330330
for (k in value) {
331-
if (Object.hasOwnProperty.call(value, k)) {
331+
if (Object.prototype.hasOwnProperty.call(value, k)) {
332332
v = str(k, value);
333333
if (v) {
334334
partial.push(quote(k) + (gap ? ': ' : ':') + v);
@@ -413,7 +413,7 @@ if (!JSON) {
413413
var k, v, value = holder[key];
414414
if (value && typeof value === 'object') {
415415
for (k in value) {
416-
if (Object.hasOwnProperty.call(value, k)) {
416+
if (Object.prototype.hasOwnProperty.call(value, k)) {
417417
v = walk(value, k);
418418
if (v !== undefined) {
419419
value[k] = v;

json_parse.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
http://www.JSON.org/json_parse.js
3-
2011-01-18
3+
2011-02-23
44
55
Public Domain.
66
@@ -47,10 +47,11 @@
4747
*/
4848

4949
/*members "", "\"", "\/", "\\", at, b, call, charAt, f, fromCharCode,
50-
hasOwnProperty, message, n, name, push, r, t, text
50+
hasOwnProperty, message, n, name, prototype, push, r, t, text
5151
*/
5252

5353
var json_parse = (function () {
54+
"use strict";
5455

5556
// This is a function that can parse a JSON text, producing a JavaScript
5657
// data structure. It is a simple, recursive descent parser. It does not use
@@ -329,7 +330,7 @@ var json_parse = (function () {
329330
var k, v, value = holder[key];
330331
if (value && typeof value === 'object') {
331332
for (k in value) {
332-
if (Object.hasOwnProperty.call(value, k)) {
333+
if (Object.prototype.hasOwnProperty.call(value, k)) {
333334
v = walk(value, k);
334335
if (v !== undefined) {
335336
value[k] = v;

json_parse_state.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
http://www.JSON.org/json_parse_state.js
3-
2011-01-18
3+
2011-02-23
44
55
Public Domain.
66
@@ -51,11 +51,12 @@
5151
/*members "", "\"", ",", "\/", ":", "[", "\\", "]", acomma, avalue, b,
5252
call, colon, container, exec, f, false, firstavalue, firstokey,
5353
fromCharCode, go, hasOwnProperty, key, length, n, null, ocomma, okey,
54-
ovalue, pop, push, r, replace, slice, state, t, test, true, value, "{",
55-
"}"
54+
ovalue, pop, prototype, push, r, replace, slice, state, t, test, true,
55+
value, "{", "}"
5656
*/
5757

5858
var json_parse = (function () {
59+
"use strict";
5960

6061
// This function creates a JSON parse function that uses a state machine rather
6162
// than the dangerous eval function to parse a JSON text.
@@ -380,7 +381,7 @@ var json_parse = (function () {
380381
var k, v, value = holder[key];
381382
if (value && typeof value === 'object') {
382383
for (k in value) {
383-
if (Object.hasOwnProperty.call(value, k)) {
384+
if (Object.prototype.hasOwnProperty.call(value, k)) {
384385
v = walk(value, k);
385386
if (v !== undefined) {
386387
value[k] = v;

0 commit comments

Comments
 (0)