@hypefactors/js-get
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="1.0.3"></a> | ||
## [1.0.3](https://github.com/hypefactors/js-get/compare/v1.0.2...v1.0.3) (2018-04-22) | ||
<a name="1.0.2"></a> | ||
@@ -7,0 +12,0 @@ ## [1.0.2](https://github.com/hypefactors/js-get/compare/v1.0.1...v1.0.2) (2018-04-22) |
@@ -1,44 +0,1 @@ | ||
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var idDev = process.env.NODE_ENV === 'development'; | ||
function warn(message) { | ||
idDev && console.warn('[@hypefactors/get]: ' + message); | ||
} | ||
/** | ||
* Deeply fetch dot notated strings from object. | ||
* Has fallback if value does not exist | ||
* @param {String} path - Dot notated string | ||
* @param {Object} source - Object to traverse | ||
* @param {*} fallback - Fallback value | ||
* @return {*} | ||
*/ | ||
function get(source, path) { | ||
var fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
if (typeof path !== 'string') { | ||
warn('Expected a string in the first argument, got ' + (typeof path === 'undefined' ? 'undefined' : _typeof(path))); | ||
return fallback; | ||
} | ||
if ((typeof source === 'undefined' ? 'undefined' : _typeof(source)) !== 'object') { | ||
warn('Expected an Object/Array in the second argument, got ' + (typeof source === 'undefined' ? 'undefined' : _typeof(source))); | ||
return fallback; | ||
} | ||
try { | ||
return path.trim().replace(/\[(\d+)]/g, '.$1').split('.').reduce(function (obj, current) { | ||
if (!obj[current]) throw new Error('The "' + path + '" could not be resolved in ' + JSON.stringify(obj) + ' at key "' + current + '"'); | ||
return obj[current]; | ||
}, source); | ||
} catch (err) { | ||
warn(err); | ||
return fallback; | ||
} | ||
} | ||
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},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; |
@@ -1,42 +0,1 @@ | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var idDev = process.env.NODE_ENV === 'development'; | ||
function warn(message) { | ||
idDev && console.warn('[@hypefactors/get]: ' + message); | ||
} | ||
/** | ||
* Deeply fetch dot notated strings from object. | ||
* Has fallback if value does not exist | ||
* @param {String} path - Dot notated string | ||
* @param {Object} source - Object to traverse | ||
* @param {*} fallback - Fallback value | ||
* @return {*} | ||
*/ | ||
function get(source, path) { | ||
var fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
if (typeof path !== 'string') { | ||
warn('Expected a string in the first argument, got ' + (typeof path === 'undefined' ? 'undefined' : _typeof(path))); | ||
return fallback; | ||
} | ||
if ((typeof source === 'undefined' ? 'undefined' : _typeof(source)) !== 'object') { | ||
warn('Expected an Object/Array in the second argument, got ' + (typeof source === 'undefined' ? 'undefined' : _typeof(source))); | ||
return fallback; | ||
} | ||
try { | ||
return path.trim().replace(/\[(\d+)]/g, '.$1').split('.').reduce(function (obj, current) { | ||
if (!obj[current]) throw new Error('The "' + path + '" could not be resolved in ' + JSON.stringify(obj) + ' at key "' + current + '"'); | ||
return obj[current]; | ||
}, source); | ||
} catch (err) { | ||
warn(err); | ||
return fallback; | ||
} | ||
} | ||
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},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; |
@@ -1,50 +0,1 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global.get = factory()); | ||
}(this, (function () { 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var idDev = process.env.NODE_ENV === 'development'; | ||
function warn(message) { | ||
idDev && console.warn('[@hypefactors/get]: ' + message); | ||
} | ||
/** | ||
* Deeply fetch dot notated strings from object. | ||
* Has fallback if value does not exist | ||
* @param {String} path - Dot notated string | ||
* @param {Object} source - Object to traverse | ||
* @param {*} fallback - Fallback value | ||
* @return {*} | ||
*/ | ||
function get(source, path) { | ||
var fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; | ||
if (typeof path !== 'string') { | ||
warn('Expected a string in the first argument, got ' + (typeof path === 'undefined' ? 'undefined' : _typeof(path))); | ||
return fallback; | ||
} | ||
if ((typeof source === 'undefined' ? 'undefined' : _typeof(source)) !== 'object') { | ||
warn('Expected an Object/Array in the second argument, got ' + (typeof source === 'undefined' ? 'undefined' : _typeof(source))); | ||
return fallback; | ||
} | ||
try { | ||
return path.trim().replace(/\[(\d+)]/g, '.$1').split('.').reduce(function (obj, current) { | ||
if (!obj[current]) throw new Error('The "' + path + '" could not be resolved in ' + JSON.stringify(obj) + ' at key "' + current + '"'); | ||
return obj[current]; | ||
}, source); | ||
} catch (err) { | ||
warn(err); | ||
return fallback; | ||
} | ||
} | ||
return get; | ||
}))); | ||
!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}}}); |
{ | ||
"name": "@hypefactors/js-get", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Retrieve deeply nested properties from mixed objects and arrays using dot notation.", | ||
@@ -61,2 +61,3 @@ "main": "dist/get.js", | ||
"rollup-plugin-babel": "^3.0.3", | ||
"rollup-plugin-uglify": "^3.0.0", | ||
"standard-version": "^4.3.0" | ||
@@ -63,0 +64,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
13676
17
12