@aofl/object-utils
Advanced tools
Comparing version 4.0.0-alpha.21 to 4.0.0-alpha.22
@@ -1,2 +0,2 @@ | ||
!function(){"use strict";var n={n:function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},d:function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o:function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},r:function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},e={};n.r(e),n.d(e,{deepAssign:function(){return u},deepFreeze:function(){return f},defaults:function(){return b},get:function(){return a},has:function(){return l},recurseObjectByPath:function(){return t},set:function(){return s}});var t=function(n,e,t){return function n(e,r){var o="",u=[];return e.length&&(o=e[0],u=e.slice(1)),t(o,u,r,n)}(""===e?"":e.split("."),n)},r=require("@babel/runtime/helpers/defineProperty"),o=n.n(r),u=function(n,e,r){return t(n,e,(function(n,e,t,u){return 0===e.length?""===n?Object.assign({},t,r):Object.assign({},t,o()({},n,Object.assign({},t[n],r))):Object.assign({},t,o()({},n,u(e,t[n])))}))},i=require("@babel/runtime/helpers/typeof"),c=n.n(i);function f(n){for(var e in Object.freeze(n),n)!Object.hasOwnProperty.call(n,e)||null===n[e]||"object"!==c()(n[e])&&"function"!=typeof n[e]||Object.isFrozen(n[e])||f(n[e]);return n}var a=function(n,e){return t(n,e,(function(n,e,t,r){return 0===e.length?t[n]:void 0!==t[n]?r(e,t[n]):void 0}))},l=function(n,e){return t(n,e,(function(n,e,t,r){return 0===e.length?void 0!==t[n]:void 0!==t[n]&&r(e,t[n])}))},s=function(n,e,r){return t(n,e,(function(n,e,t,o){if(0!==e.length)return void 0===t[n]&&(t[n]={}),o(e,t[n]);t[n]=r}))},b=function(n,e){!function n(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(void 0===e[r]?Array.isArray(t[r])?e[r]=[].concat(t[r]):"object"===c()(t[r])?(e[r]={},n(e[r],t[r])):e[r]=t[r]:"object"!==c()(e[r])||Array.isArray(e[r])||n(e[r],t[r]))}(n,e)};module.exports=e}(); | ||
!function(){"use strict";var e={d:function(n,t){for(var r in t)e.o(t,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:t[r]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{deepAssign:function(){return o},deepFreeze:function(){return i},defaults:function(){return l},get:function(){return c},has:function(){return f},recurseObjectByPath:function(){return t},set:function(){return a}});var t=function(e,n,t){return function e(n,r){var o="",u=[];return n.length&&(o=n[0],u=n.slice(1)),t(o,u,r,e)}(""===n?[]:n.split("."),e)},r=require("@babel/runtime/helpers/defineProperty"),o=function(e,n,o){return t(e,n,(function(e,n,t,u){return 0===n.length?""===e?Object.assign({},t,o):Object.assign({},t,r({},e,Object.assign({},t[e],o))):Object.assign({},t,r({},e,u(n,t[e])))}))},u=require("@babel/runtime/helpers/typeof");function i(e){for(var n in Object.freeze(e),e)!Object.hasOwnProperty.call(e,n)||null===e[n]||"object"!==u(e[n])&&"function"!=typeof e[n]||Object.isFrozen(e[n])||i(e[n]);return e}var c=function(e,n){return t(e,n,(function(e,n,t,r){return 0===n.length?t[e]:void 0!==t[e]?r(n,t[e]):void 0}))},f=function(e,n){return t(e,n,(function(e,n,t,r){return 0===n.length?void 0!==t[e]:void 0!==t[e]&&r(n,t[e])}))},a=function(e,n,r){return t(e,n,(function(e,n,t,o){if(0!==n.length)return void 0===t[e]&&(t[e]={}),o(n,t[e]);t[e]=r}))},l=function(e,n){!function e(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(void 0===n[r]?Array.isArray(t[r])?n[r]=[].concat(t[r]):"object"===u(t[r])?(n[r]={},e(n[r],t[r])):n[r]=t[r]:"object"!==u(n[r])||Array.isArray(n[r])||e(n[r],t[r]))}(e,n)};module.exports=n}(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@aofl/object-utils", | ||
"version": "4.0.0-alpha.21", | ||
"version": "4.0.0-alpha.22", | ||
"description": "A small collection of Object utility functions designed to have a small footprint (20b gz) and be performant", | ||
"main": "index.js", | ||
"browser": "dist/index.js", | ||
"module": "index.js", | ||
"typings": "types.d.ts", | ||
"scripts": {}, | ||
"keywords": [ | ||
@@ -17,2 +12,42 @@ "aofljs", | ||
], | ||
"type": "module", | ||
"main": "lib/index.js", | ||
"browser": "dist/index.js", | ||
"module": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"exports": { | ||
".": { | ||
"default": "./lib/index.js" | ||
}, | ||
"./lib/core.js": { | ||
"default": "./lib/core.js" | ||
}, | ||
"./lib/deep-assign.js": { | ||
"default": "./lib/deep-assign.js" | ||
}, | ||
"./lib/deep-freeze.js": { | ||
"default": "./lib/deep-freeze.js" | ||
}, | ||
"./lib/defaults.js": { | ||
"default": "./lib/defaults.js" | ||
}, | ||
"./lib/get.js": { | ||
"default": "./lib/get.js" | ||
}, | ||
"./lib/has.js": { | ||
"default": "./lib/has.js" | ||
}, | ||
"./lib/set.js": { | ||
"default": "./lib/set.js" | ||
} | ||
}, | ||
"scripts": { | ||
"clean": "rm -rf dist lib", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"tsc": "cross-env NODE_ENV=production tsc -p tsconfig.json", | ||
"build-ci": "npm run clean && npm run tsc && cross-env NODE_ENV=production aofl build --debug --config .aofl.cjs", | ||
"build": "npm run clean && npm run tsc && cross-env NODE_ENV=production aofl build --config .aofl.cjs", | ||
"build:dev": "npm run tsc && cross-env NODE_ENV=development aofl build --config .aofl.cjs", | ||
"prepublishOnly": "npm run build-ci" | ||
}, | ||
"repository": { | ||
@@ -29,7 +64,4 @@ "type": "git", | ||
"devDependencies": { | ||
"@aofl/cli": "^4.0.0-alpha.21", | ||
"cross-env": "^7.0.3", | ||
"jsdoc": "^3.6.6", | ||
"tsd-jsdoc": "^2.5.0" | ||
"cross-env": "^7.0.3" | ||
} | ||
} |
# @aofl/object-utils | ||
A small collection of Object utility functions designed to have a small footprint (20b gz) and be performant. | ||
A small collection of Object utility functions designed to have a small footprint and be performant. | ||
[Api Documentation](https://ageoflearning.github.io/aofl/v3.x/api-docs/module-@aofl_object-utils.html) | ||
# | ||
[Api Documentation](https://ageoflearning.github.io/aofl/v4.x/api-docs/modules/_aofl_object_utils.html#deepAssign) | ||
--- | ||
@@ -27,89 +29,1 @@ ## Why? | ||
``` | ||
--- | ||
## Methods | ||
### deepAssign | ||
Recursively calls Object.assign along the specified path. | ||
#### Arguments | ||
| Name | Type | Description | | ||
|-------------|--------|----------------| | ||
| leftSource | Object | Left source | | ||
| path | String | Path to target | | ||
| rightSource | Object | Right source | | ||
#### Example | ||
```javascript | ||
const user = { | ||
name: 'Alan', | ||
account: { | ||
active: true, | ||
products: { | ||
1: true, | ||
2: true, | ||
3: true | ||
} | ||
}, | ||
preferences: { | ||
locale: 'en-US' | ||
} | ||
}; | ||
const user2 = deepAssign(user, 'account.products', { | ||
2: false | ||
}); | ||
// { // new ref | ||
// name: 'Alan', | ||
// account: { // new ref | ||
// active: true, | ||
// products: { // new ref | ||
// 1: true, | ||
// 2: false, // updated value | ||
// 3: true | ||
// } | ||
// }, | ||
// preferences: { // same ref | ||
// locale: 'en-US' | ||
// } | ||
// }; | ||
console.log(user2 === user); // expected result: false | ||
console.log(user2.account === user.account); // expected result: false | ||
console.log(user2.preferences === user.preferences); // expected result: true | ||
``` | ||
--- | ||
### deepFreeze | ||
Recursively calls Object.freeze on objects properties. | ||
*Note: this method should only be used in development environments and disabled in production* | ||
#### Arguments | ||
| Name | Type | Description | | ||
|---------|--------|----------------| | ||
| source | Object | Source Object | | ||
#### Example | ||
```javascript | ||
let user = deepFreeze({ | ||
name: 'Alan', | ||
account: { | ||
active: true, | ||
products: { | ||
1: true, | ||
2: true, | ||
3: true | ||
} | ||
}, | ||
preferences: { | ||
locale: 'en-US' | ||
} | ||
}); | ||
user.account.active = false; // Throws an error in strict mode | ||
console.log(user.account.active); // expected output: true | ||
``` | ||
--- |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
29315
1
30
353
Yes
4
29
1