immutable-assign
Advanced tools
Comparing version 1.0.16 to 1.0.17
@@ -13,3 +13,3 @@ "use strict"; | ||
// Browser globals (root is window) | ||
var require_1 = function (name) { | ||
var browserRequire = function (name) { | ||
if (name == "deep-freeze" && root.deepFreeze) { | ||
@@ -20,3 +20,3 @@ return root.deepFreeze; | ||
}; | ||
root.iassign = factory(require_1, {}); | ||
root.iassign = factory(browserRequire, {}); | ||
} | ||
@@ -183,4 +183,6 @@ })(this, function (require, exports) { | ||
if (!option.disableAllCheck && !option.disableExtraStatementCheck) { | ||
var otherBodyText = bodyText.substr(0, returnIndex).trim(); | ||
if (otherBodyText != "" && otherBodyText != '"use strict";') { | ||
var otherBodyText = bodyText.substr(0, returnIndex); | ||
otherBodyText = otherBodyText.replace(/['"]use strict['"];*/g, ""); | ||
otherBodyText = otherBodyText.trim(); | ||
if (otherBodyText != "") { | ||
throw new Error("getProp() function has statements other than 'return': " + otherBodyText); | ||
@@ -187,0 +189,0 @@ } |
@@ -61,7 +61,12 @@ // Karma configuration | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
// If our browser install to the default location, we need to set the environment variable point to the installation path. | ||
// | ||
// If browsers are not installed to the default location, you need to set the environment variable pointing to the installation path. | ||
// E.g., SET FIREFOX_BIN="C:\Program Files (x86)\MozillaFirefox4x\firefox.exe" | ||
// Refer to http://karma-runner.github.io/1.0/config/browsers.html | ||
browsers: ["Chrome", "Firefox", "IE", "PhantomJS" ], | ||
browsers: ["Chrome", "Firefox", "IE", "PhantomJS"], | ||
// To Run Edge, please install https://github.com/nicolasmccurdy/karma-edge-launcher manually. | ||
//browsers: ["Edge"], | ||
//browsers: ["Chrome", "Firefox", "IE", "Edge", "PhantomJS"], | ||
// Continuous Integration mode | ||
@@ -68,0 +73,0 @@ // if true, Karma captures browsers, runs the tests and exits |
{ | ||
"name": "immutable-assign", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "", | ||
@@ -42,2 +42,3 @@ "main": "src/iassign.js", | ||
"karma-chrome-launcher": "^1.0.1", | ||
"edge-launcher": "*", | ||
"karma-firefox-launcher": "^1.0.0", | ||
@@ -44,0 +45,0 @@ "karma-ie-launcher": "^1.0.0", |
@@ -199,4 +199,4 @@ # immutable-assign (iassign.js) | ||
* 1.0.16 - Tested in Node.js and major browsers (IE 11, Chrome 52, Firefox 47, PhantomJS 2) | ||
* 1.0.16 - Tested in Node.js and major browsers (IE 11, Chrome 52, Firefox 47, Edge 13, PhantomJS 2) | ||
"use strict"; | ||
(function (root, factory) { | ||
if (typeof module === 'object' && typeof module.exports === 'object') { | ||
var v = factory(require, exports); if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === 'function' && define.amd) { | ||
define(["require", "exports"], factory); | ||
} else { | ||
// Browser globals (root is window) | ||
var require = function(name) { | ||
if (name == "deep-freeze" && root.deepFreeze) { | ||
return root.deepFreeze; | ||
} | ||
if (name == "lodash" && root._) { | ||
return root._; | ||
} | ||
if (typeof module === 'object' && typeof module.exports === 'object') { | ||
var v = factory(require, exports); if (v !== undefined) module.exports = v; | ||
} | ||
else if (typeof define === 'function' && define.amd) { | ||
define(["require", "exports"], factory); | ||
} else { | ||
// Browser globals (root is window) | ||
var browserRequire = function(name) { | ||
if (name == "deep-freeze" && root.deepFreeze) { | ||
return root.deepFreeze; | ||
} | ||
if (name.indexOf("iassign") > -1 && root.iassign) { | ||
return root.iassign; | ||
} | ||
if (name == "lodash" && root._) { | ||
return root._; | ||
} | ||
throw new Error("Unable to require: " + name); | ||
if (name.indexOf("iassign") > -1 && root.iassign) { | ||
return root.iassign; | ||
} | ||
throw new Error("Unable to require: " + name); | ||
} | ||
factory(browserRequire, {}); | ||
} | ||
factory(require, {}); | ||
} | ||
})(this, function (require, exports) { | ||
@@ -306,2 +307,3 @@ | ||
// Will cause error but not the close brack error. | ||
xit("extra '[' should throw exception", function () { | ||
@@ -318,2 +320,3 @@ var o1 = { a: { b: { c: [[{ d: 11, e: 12 }], [{ d: 21, e: 22 }], [{ d: 31, e: 32 }]] } } }; | ||
// Will cause error but not the open brack error. | ||
xit("extra ']' should throw exception", function () { | ||
@@ -359,2 +362,54 @@ var o1 = { a: { b: { c: [[{ d: 11, e: 12 }], [{ d: 21, e: 22 }], [{ d: 31, e: 32 }]] } } }; | ||
}); | ||
it("getProp() function has use strict statements should not throw exception", function () { | ||
var o1 = { a: { b: { c: [[{ d: 11, e: 12 }], [{ d: 21, e: 22 }], [{ d: 31, e: 32 }]], c2: {} }, b2: {} }, a2: {} }; | ||
deepFreeze(o1); | ||
var o2 = iassign( | ||
o1, | ||
function (o) { | ||
"use strict";"use strict"; | ||
"use strict";'use strict' | ||
"use strict" | ||
'use strict'; | ||
'use strict' | ||
return o.a.b.c[0][0]; | ||
}, | ||
function (ci) { | ||
ci.d++; return ci; | ||
} | ||
); | ||
// | ||
// Jasmine Tests | ||
// | ||
// expect o1 has not been changed | ||
expect(o1).toEqual({ a: { b: { c: [[{ d: 11, e: 12 }], [{ d: 21, e: 22 }], [{ d: 31, e: 32 }]], c2: {} }, b2: {} }, a2: {} }) | ||
// expect o2 inner property has been updated. | ||
expect(o2.a.b.c[0][0].d).toBe(12); | ||
// expect object graph for changed property in o2 is now different from (!==) o1. | ||
expect(o2).not.toBe(o1); | ||
expect(o2.a).not.toBe(o1.a); | ||
expect(o2.a.b).not.toBe(o1.a.b); | ||
expect(o2.a.b.c).not.toBe(o1.a.b.c); | ||
expect(o2.a.b.c[0]).not.toBe(o1.a.b.c[0]); | ||
expect(o2.a.b.c[0][0]).not.toBe(o1.a.b.c[0][0]); | ||
expect(o2.a.b.c[0][0].d).not.toBe(o1.a.b.c[0][0].d); | ||
// expect object graph for unchanged property in o2 is still equal to (===) o1. | ||
expect(o2.a2).toBe(o1.a2); | ||
expect(o2.a.b2).toBe(o1.a.b2); | ||
expect(o2.a.b.c2).toBe(o1.a.b.c2); | ||
expect(o2.a.b.c[0][0].e).toBe(o1.a.b.c[0][0].e); | ||
expect(o2.a.b.c[1][0]).toBe(o1.a.b.c[1][0]); | ||
expect(o2.a.b.c[2][0]).toBe(o1.a.b.c[2][0]); | ||
}); | ||
@@ -361,0 +416,0 @@ it("getProp() disableExtraStatementCheck", function () { |
@@ -13,3 +13,3 @@ "use strict"; | ||
// Browser globals (root is window) | ||
var require_1 = function (name) { | ||
var browserRequire = function (name) { | ||
if (name == "deep-freeze" && root.deepFreeze) { | ||
@@ -26,3 +26,3 @@ return root.deepFreeze; | ||
}; | ||
factory(require_1, {}); | ||
factory(browserRequire, {}); | ||
} | ||
@@ -29,0 +29,0 @@ })(this, function (require, exports) { |
@@ -12,3 +12,3 @@ | ||
// Browser globals (root is window) | ||
let require = (name) => { | ||
let browserRequire = (name) => { | ||
if (name == "deep-freeze" && root.deepFreeze) { | ||
@@ -28,3 +28,3 @@ return root.deepFreeze; | ||
} | ||
factory(require, {}); | ||
factory(browserRequire, {}); | ||
} | ||
@@ -31,0 +31,0 @@ })(this, function (require, exports) { |
@@ -13,3 +13,3 @@ "use strict"; | ||
// Browser globals (root is window) | ||
var require_1 = function (name) { | ||
var browserRequire = function (name) { | ||
if (name == "deep-freeze" && root.deepFreeze) { | ||
@@ -20,3 +20,3 @@ return root.deepFreeze; | ||
}; | ||
root.iassign = factory(require_1, {}); | ||
root.iassign = factory(browserRequire, {}); | ||
} | ||
@@ -183,4 +183,6 @@ })(this, function (require, exports) { | ||
if (!option.disableAllCheck && !option.disableExtraStatementCheck) { | ||
var otherBodyText = bodyText.substr(0, returnIndex).trim(); | ||
if (otherBodyText != "" && otherBodyText != '"use strict";') { | ||
var otherBodyText = bodyText.substr(0, returnIndex); | ||
otherBodyText = otherBodyText.replace(/['"]use strict['"];*/g, ""); | ||
otherBodyText = otherBodyText.trim(); | ||
if (otherBodyText != "") { | ||
throw new Error("getProp() function has statements other than 'return': " + otherBodyText); | ||
@@ -187,0 +189,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict" | ||
"use strict"; | ||
@@ -31,3 +31,3 @@ declare var define; | ||
// Browser globals (root is window) | ||
let require = (name) => { | ||
let browserRequire = (name) => { | ||
if (name == "deep-freeze" && root.deepFreeze) { | ||
@@ -39,3 +39,3 @@ return root.deepFreeze; | ||
} | ||
root.iassign = factory(require, {}); | ||
root.iassign = factory(browserRequire, {}); | ||
} | ||
@@ -241,4 +241,6 @@ })(this, function (require, exports) { | ||
if (!option.disableAllCheck && !option.disableExtraStatementCheck) { | ||
let otherBodyText = bodyText.substr(0, returnIndex).trim(); | ||
if (otherBodyText != "" && otherBodyText != '"use strict";') { | ||
let otherBodyText = bodyText.substr(0, returnIndex); | ||
otherBodyText = otherBodyText.replace(/['"]use strict['"];*/g, ""); | ||
otherBodyText = otherBodyText.trim(); | ||
if (otherBodyText != "") { | ||
throw new Error("getProp() function has statements other than 'return': " + otherBodyText); | ||
@@ -245,0 +247,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
818330
23695
16