@hypefactors/js-get
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="1.1.0"></a> | ||
# [1.1.0](https://github.com/hypefactors/js-get/compare/v1.0.3...v1.1.0) (2018-04-22) | ||
### Features | ||
* Improved the performance and allowed array of keys as a path description ([5bf4305](https://github.com/hypefactors/js-get/commit/5bf4305)) | ||
<a name="1.0.3"></a> | ||
@@ -7,0 +17,0 @@ ## [1.0.3](https://github.com/hypefactors/js-get/compare/v1.0.2...v1.0.3) (2018-04-22) |
@@ -1,1 +0,1 @@ | ||
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},idDev="development"===process.env.NODE_ENV;function warn(e){idDev&&console.warn("[@hypefactors/get]: "+e)}function get(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if("string"!=typeof t)return warn("Expected a string in the first argument, got "+(void 0===t?"undefined":_typeof(t))),n;if("object"!==(void 0===e?"undefined":_typeof(e)))return warn("Expected an Object/Array in the second argument, got "+(void 0===e?"undefined":_typeof(e))),n;try{return t.trim().replace(/\[(\d+)]/g,".$1").split(".").reduce(function(e,n){if(!e[n])throw new Error('The "'+t+'" could not be resolved in '+JSON.stringify(e)+' at key "'+n+'"');return e[n]},e)}catch(e){return warn(e),n}}module.exports=get; | ||
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},inDebug=["development","local","debug"].includes(process.env.NODE_ENV);function warn(e){inDebug&&console.warn("[@hypefactors/get]: "+e)}function get(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if("object"!==(void 0===e?"undefined":_typeof(e)))return warn("Expected an Object/Array in the second argument, got "+(void 0===e?"undefined":_typeof(e))),o;try{for(var n=Array.isArray(t)?t:t.split("."),r=0;r<n.length;r++){var u=n[r];if(!e||!e.hasOwnProperty(u))return warn('The "'+t+'" could not be resolved at key "'+u+'"'),o;e=e[u]}return e}catch(e){return o}}module.exports=get; |
@@ -1,1 +0,1 @@ | ||
var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},idDev="development"===process.env.NODE_ENV;function warn(e){idDev&&console.warn("[@hypefactors/get]: "+e)}function get(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if("string"!=typeof t)return warn("Expected a string in the first argument, got "+(void 0===t?"undefined":_typeof(t))),n;if("object"!==(void 0===e?"undefined":_typeof(e)))return warn("Expected an Object/Array in the second argument, got "+(void 0===e?"undefined":_typeof(e))),n;try{return t.trim().replace(/\[(\d+)]/g,".$1").split(".").reduce(function(e,n){if(!e[n])throw new Error('The "'+t+'" could not be resolved in '+JSON.stringify(e)+' at key "'+n+'"');return e[n]},e)}catch(e){return warn(e),n}}export default get; | ||
var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},inDebug=["development","local","debug"].includes(process.env.NODE_ENV);function warn(e){inDebug&&console.warn("[@hypefactors/get]: "+e)}function get(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if("object"!==(void 0===e?"undefined":_typeof(e)))return warn("Expected an Object/Array in the second argument, got "+(void 0===e?"undefined":_typeof(e))),o;try{for(var n=Array.isArray(t)?t:t.split("."),r=0;r<n.length;r++){var y=n[r];if(!e||!e.hasOwnProperty(y))return warn('The "'+t+'" could not be resolved at key "'+y+'"'),o;e=e[y]}return e}catch(e){return o}}export default get; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.get=t()}(this,function(){"use strict";var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t="development"===process.env.NODE_ENV;function n(e){t&&console.warn("[@hypefactors/get]: "+e)}return function(t,o){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if("string"!=typeof o)return n("Expected a string in the first argument, got "+(void 0===o?"undefined":e(o))),r;if("object"!==(void 0===t?"undefined":e(t)))return n("Expected an Object/Array in the second argument, got "+(void 0===t?"undefined":e(t))),r;try{return o.trim().replace(/\[(\d+)]/g,".$1").split(".").reduce(function(e,t){if(!e[t])throw new Error('The "'+o+'" could not be resolved in '+JSON.stringify(e)+' at key "'+t+'"');return e[t]},t)}catch(e){return n(e),r}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.get=t()}(this,function(){"use strict";var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t=["development","local","debug"].includes(process.env.NODE_ENV);function o(e){t&&console.warn("[@hypefactors/get]: "+e)}return function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if("object"!==(void 0===t?"undefined":e(t)))return o("Expected an Object/Array in the second argument, got "+(void 0===t?"undefined":e(t))),r;try{for(var f=Array.isArray(n)?n:n.split("."),i=0;i<f.length;i++){var u=f[i];if(!t||!t.hasOwnProperty(u))return o('The "'+n+'" could not be resolved at key "'+u+'"'),r;t=t[u]}return t}catch(e){return r}}}); |
{ | ||
"name": "@hypefactors/js-get", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Retrieve deeply nested properties from mixed objects and arrays using dot notation.", | ||
@@ -12,3 +12,4 @@ "main": "dist/get.js", | ||
"build": "rollup -c", | ||
"test": "jest", | ||
"test": "jest --coverage", | ||
"benchmark": "npm run build && node test/benchmarks/get.b.js", | ||
"lint": "eslint src test/specs", | ||
@@ -50,2 +51,3 @@ "lint:fix": "npm run lint -- --fix", | ||
"babel-preset-env": "^1.6.1", | ||
"benchmark": "^2.1.4", | ||
"eslint": "^4.19.1", | ||
@@ -52,0 +54,0 @@ "eslint-config-standard": "^11.0.0", |
@@ -18,2 +18,3 @@ # JS-Get | ||
- Fast | ||
- Lightweight, well-documented source code bundled as CJS, EM and UMD | ||
@@ -57,8 +58,16 @@ - 100% test coverage | ||
get(profile, 'name.first') // 'John' | ||
get(profile, 'activities[0]') // 'sports' | ||
get(profile, 'activities.0') // 'sports' | ||
get(profile, 'activities[1].frequency') // 'weekly' | ||
get(profile, 'activities.1.frequency') // 'weekly' | ||
get(profile, 'foobar', 'not-found') // 'not-found' | ||
``` | ||
Or using array syntax: | ||
```javascript | ||
get(profile, ['age']) // 15 | ||
get(profile, ['name', 'first']) // 'John' | ||
get(profile, ['activities', '0']) // 'sports' | ||
get(profile, ['activities', '1', 'frequency']) // 'weekly' | ||
get(profile, ['foobar'], 'not-found') // 'not-found' | ||
``` | ||
## Contributing | ||
@@ -65,0 +74,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
13960
78
18