Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

identitate

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

identitate - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

CHANGELOG.md

336

dist/identitate.js

@@ -10,3 +10,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

root["identitate"] = factory();
})(typeof self !== 'undefined' ? self : this, function() {
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap

@@ -50,10 +50,30 @@ /******/ // The module cache

/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules

@@ -74,110 +94,96 @@ /******/ __webpack_require__.n = function(module) {

/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js");
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/******/ ({
/***/ "./node_modules/pathington/es/constants.js":
/*!*************************************************!*\
!*** ./node_modules/pathington/es/constants.js ***!
\*************************************************/
/*! exports provided: CACHE, DOTTY_WITH_BRACKETS_SYNTAX, MAX_CACHE_SIZE, NUMBER, QUOTED_KEY, VALID_QUOTES, VALID_KEY, WHITE_SPACE */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return DOTTY_WITH_BRACKETS_SYNTAX_REGEXP; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return INVALID_JAVASCRIPT_CHARACTERS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return INVALID_JAVASCRIPT_LEADING_CHARACTER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return QUOTES_REGEXP; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return QUOTES_GLOBAL_REGEXP; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return WHITE_SPACE; });
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CACHE", function() { return CACHE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DOTTY_WITH_BRACKETS_SYNTAX", function() { return DOTTY_WITH_BRACKETS_SYNTAX; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_CACHE_SIZE", function() { return MAX_CACHE_SIZE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NUMBER", function() { return NUMBER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QUOTED_KEY", function() { return QUOTED_KEY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VALID_QUOTES", function() { return VALID_QUOTES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VALID_KEY", function() { return VALID_KEY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WHITE_SPACE", function() { return WHITE_SPACE; });
/**
* @constant {RegExp} DOTTY_WITH_BRACKETS_SYNTAX_REGEXP
* @constant {Object} CACHE
*
* @property {function} clear clear the cache results
* @property {Object} results the map of path => array results
* @property {number} size the size of the cache
*/
var DOTTY_WITH_BRACKETS_SYNTAX_REGEXP = /\w+|"[^"]+"/g;
var CACHE = {
clear: function clear() {
CACHE.results = {};
CACHE.size = 0;
},
results: {},
size: 0
};
/**
* @constant {RegExp} DOTTY_WITH_BRACKETS_SYNTAX
*/
var DOTTY_WITH_BRACKETS_SYNTAX = /"[^"]+"|`[^`]+`|'[^']+'|[^.[\]]+/g;
/**
* @constant {RegExp} INVALID_JAVASCRIPT_CHARACTERS
* @constant {number} MAX_CACHE_SIZE
*/
var INVALID_JAVASCRIPT_CHARACTERS = /[^A-Za-z0-9_$]/;
var MAX_CACHE_SIZE = 500;
/**
* @constant {RegExp} INVALID_JAVASCRIPT_LEADING_CHARACTER
* @constant {RegExp} NUMBER
*/
var INVALID_JAVASCRIPT_LEADING_CHARACTER = /[^A-Za-z_$]/;
var NUMBER = /^\d+$/i;
/**
* @constant {RegExp} QUOTES_REGEXP
* @constant {RegExp} QUOTED_KEY
*/
var QUOTES_REGEXP = /['|"|`]/;
var QUOTED_KEY = /^"[^"]+"|`[^`]+`|'[^']+'$/;
/**
* @constant {RegExp} QUOTES_GLOBAL_REGEXP
* @constant {Array<string>} VALID_QUOTES
*/
var QUOTES_GLOBAL_REGEXP = new RegExp(('' + QUOTES_REGEXP).slice(1, -1), 'g');
var VALID_QUOTES = /^["'`]{1}$/;
/**
* @constant {RegExp} WHITE_SPACE
* @constant {RegExp} VALID_KEY
*/
var WHITE_SPACE = /\s/g;
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createIdentity", function() { return createIdentity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identitySecond", function() { return identitySecond; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identityLast", function() { return identityLast; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identitySecondLast", function() { return identitySecondLast; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_pathington__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils__ = __webpack_require__(4);
// external dependencies
// utils
var VALID_KEY = /^\d+$|^[a-zA-Z_$][\w$]+$/;
/**
* @function createIdentity
*
* @description
* create an identity method for a specific argument index
*
* @param {number} argIndex the index of the argument to get
* @param {Array<number|string>|number|string} path the nested path to retrieve the value from
* @returns {function(...Array<*>): *} the identity method for the given argument
* @constant {RegExp} WHITE_SPACE
*/
var createIdentity = function createIdentity(argIndex, path) {
var shouldGetNestedValue = path !== void 0;
return function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var WHITE_SPACE = /\s/;
var value = args[argIndex < 0 ? args.length + argIndex : argIndex];
/***/ }),
return shouldGetNestedValue ? Object(__WEBPACK_IMPORTED_MODULE_1__utils__["a" /* getNestedProperty */])(Object(__WEBPACK_IMPORTED_MODULE_0_pathington__["a" /* parse */])(path), value) : value;
};
};
var identity = createIdentity(0);
var identitySecond = createIdentity(1);
var identityLast = createIdentity(-1);
var identitySecondLast = createIdentity(-2);
/***/ }),
/* 2 */
/***/ "./node_modules/pathington/es/index.js":
/*!*********************************************!*\
!*** ./node_modules/pathington/es/index.js ***!
\*********************************************/
/*! exports provided: create, parse */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export create */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return parse; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__constants__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils__ = __webpack_require__(3);
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "create", function() { return create; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parse", function() { return parse; });
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./node_modules/pathington/es/constants.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./node_modules/pathington/es/utils.js");
// constants
// utils
// utils
/**

@@ -193,5 +199,8 @@ * @function create

*/
var create = function create(path) {
var quote = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '"';
var create = function create(path, quote) {
if (quote === void 0) {
quote = '"';
}
if (!Array.isArray(path)) {

@@ -201,11 +210,9 @@ throw new ReferenceError('path passed must be an array');

if (quote && (quote.length !== 1 || !__WEBPACK_IMPORTED_MODULE_0__constants__["e" /* QUOTES_REGEXP */].test(quote))) {
throw new SyntaxError('quote passed is invalid, must be ", `, or \'.');
if (!_constants__WEBPACK_IMPORTED_MODULE_0__["VALID_QUOTES"].test(quote)) {
throw new SyntaxError("quote " + quote + " passed is invalid, must be \", `, or '.");
}
var pathString = path.reduce(Object(__WEBPACK_IMPORTED_MODULE_1__utils__["a" /* createGetNormalizedCreateKey */])(quote), '');
var pathString = path.reduce(Object(_utils__WEBPACK_IMPORTED_MODULE_1__["createGetNormalizedCreateKey"])(quote), '');
return pathString[0] === '.' ? pathString.slice(1) : pathString;
};
/**

@@ -220,28 +227,49 @@ * @function parse

*/
var parse = function parse(path) {
if (Array.isArray(path)) {
return path.map(__WEBPACK_IMPORTED_MODULE_1__utils__["b" /* getNormalizedParseKey */]);
if (typeof path === 'string') {
return Object(_utils__WEBPACK_IMPORTED_MODULE_1__["parseStringPath"])(path);
}
if (typeof path === 'string') {
return path ? path.replace(__WEBPACK_IMPORTED_MODULE_0__constants__["d" /* QUOTES_GLOBAL_REGEXP */], '"').match(__WEBPACK_IMPORTED_MODULE_0__constants__["a" /* DOTTY_WITH_BRACKETS_SYNTAX_REGEXP */]).map(__WEBPACK_IMPORTED_MODULE_1__utils__["b" /* getNormalizedParseKey */]) : [];
if (Array.isArray(path)) {
return path.map(_utils__WEBPACK_IMPORTED_MODULE_1__["getNormalizedParseKey"]);
}
return [path];
return [typeof path === 'number' ? path : "" + path];
};
/***/ }),
/* 3 */
/***/ "./node_modules/pathington/es/utils.js":
/*!*********************************************!*\
!*** ./node_modules/pathington/es/utils.js ***!
\*********************************************/
/*! exports provided: isNumericKey, isQuotedKey, shouldBeInBrackets, shouldBeInQuotes, createGetNormalizedCreateKey, getNormalizedParseKey, parseStringPath */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export isQuotedKey */
/* unused harmony export shouldBeInBrackets */
/* unused harmony export shouldBeInQuotes */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return createGetNormalizedCreateKey; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getNormalizedParseKey; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__constants__ = __webpack_require__(0);
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNumericKey", function() { return isNumericKey; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isQuotedKey", function() { return isQuotedKey; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldBeInBrackets", function() { return shouldBeInBrackets; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shouldBeInQuotes", function() { return shouldBeInQuotes; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createGetNormalizedCreateKey", function() { return createGetNormalizedCreateKey; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNormalizedParseKey", function() { return getNormalizedParseKey; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseStringPath", function() { return parseStringPath; });
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./node_modules/pathington/es/constants.js");
// constants
/**
* @function isNumericKey
*
* @description
* is the key passed a numeric string
*
* @param {string} key the key to test
* @returns {boolean} is the key passed a numeric string
*/
var isNumericKey = function isNumericKey(key) {
return !!key.length && _constants__WEBPACK_IMPORTED_MODULE_0__["NUMBER"].test(key);
};
/**

@@ -256,6 +284,6 @@ * @function isQuotedKey

*/
var isQuotedKey = function isQuotedKey(key) {
return __WEBPACK_IMPORTED_MODULE_0__constants__["e" /* QUOTES_REGEXP */].test(key[0]) && key[0] === key[key.length - 1];
return _constants__WEBPACK_IMPORTED_MODULE_0__["QUOTED_KEY"].test(key);
};
/**

@@ -270,6 +298,6 @@ * @function shouldBeInBrackets

*/
var shouldBeInBrackets = function shouldBeInBrackets(key) {
return typeof key === 'number' || !isNaN(+key) || isQuotedKey(key);
return typeof key === 'number' || isNumericKey(key) || isQuotedKey(key);
};
/**

@@ -284,6 +312,6 @@ * @function shouldBeInQuotes

*/
var shouldBeInQuotes = function shouldBeInQuotes(key) {
return __WEBPACK_IMPORTED_MODULE_0__constants__["b" /* INVALID_JAVASCRIPT_CHARACTERS */].test(key) || __WEBPACK_IMPORTED_MODULE_0__constants__["f" /* WHITE_SPACE */].test(key) || key.length > 1 && __WEBPACK_IMPORTED_MODULE_0__constants__["c" /* INVALID_JAVASCRIPT_LEADING_CHARACTER */].test(key[0]);
return _constants__WEBPACK_IMPORTED_MODULE_0__["WHITE_SPACE"].test(key) || !_constants__WEBPACK_IMPORTED_MODULE_0__["VALID_KEY"].test(key);
};
/**

@@ -298,12 +326,9 @@ * @function createGetNormalizedCreateKey

*/
var createGetNormalizedCreateKey = function createGetNormalizedCreateKey() {
var quote = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '"';
var createGetNormalizedCreateKey = function createGetNormalizedCreateKey(quote) {
return function (existingString, key) {
var normalizedKey = shouldBeInQuotes(key) ? '' + quote + key + quote : key;
return shouldBeInBrackets(normalizedKey) ? existingString + '[' + normalizedKey + ']' : existingString + '.' + normalizedKey;
var normalizedKey = shouldBeInQuotes(key) ? "" + quote + key + quote : key;
return shouldBeInBrackets(normalizedKey) ? existingString + "[" + normalizedKey + "]" : existingString + "." + normalizedKey;
};
};
/**

@@ -318,13 +343,90 @@ * @function getNormalizedParseKey

*/
var getNormalizedParseKey = function getNormalizedParseKey(key) {
return isQuotedKey(key) ? key.slice(1, -1) : isNaN(+key) ? key : +key;
var cleanKey = isQuotedKey(key) ? key.substring(1, key.length - 1) : key;
return isNumericKey(cleanKey) ? +cleanKey : cleanKey;
};
/**
* @function parsePath
*
* @description
* parse the path, memoizing the results
*
* @param {string} path the path to parse
* @returns {Array<number|string>} the parsed path
*/
var parseStringPath = function parseStringPath(path) {
if (_constants__WEBPACK_IMPORTED_MODULE_0__["CACHE"].results[path]) {
return _constants__WEBPACK_IMPORTED_MODULE_0__["CACHE"].results[path];
}
if (_constants__WEBPACK_IMPORTED_MODULE_0__["CACHE"].size > _constants__WEBPACK_IMPORTED_MODULE_0__["MAX_CACHE_SIZE"]) {
_constants__WEBPACK_IMPORTED_MODULE_0__["CACHE"].clear();
}
_constants__WEBPACK_IMPORTED_MODULE_0__["CACHE"].results[path] = path ? path.match(_constants__WEBPACK_IMPORTED_MODULE_0__["DOTTY_WITH_BRACKETS_SYNTAX"]).map(getNormalizedParseKey) : [path];
_constants__WEBPACK_IMPORTED_MODULE_0__["CACHE"].size++;
return _constants__WEBPACK_IMPORTED_MODULE_0__["CACHE"].results[path];
};
/***/ }),
/* 4 */
/***/ "./src/index.js":
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
/*! exports provided: createIdentity, identity, identitySecond, identityLast, identitySecondLast */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getNestedProperty; });
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createIdentity", function() { return createIdentity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identity", function() { return identity; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identitySecond", function() { return identitySecond; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identityLast", function() { return identityLast; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "identitySecondLast", function() { return identitySecondLast; });
/* harmony import */ var pathington__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! pathington */ "./node_modules/pathington/es/index.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ "./src/utils.js");
// external dependencies
// utils
/**
* @function createIdentity
*
* @description
* create an identity method for a specific argument index
*
* @param {number} argIndex the index of the argument to get
* @param {Array<number|string>|number|string} path the nested path to retrieve the value from
* @returns {function(...Array<*>): *} the identity method for the given argument
*/
var createIdentity = function createIdentity(argIndex, path) {
var shouldGetNestedValue = path !== void 0;
return function () {
// eslint-disable-next-line prefer-rest-params
var value = arguments[argIndex < 0 ? arguments.length + argIndex : argIndex];
return shouldGetNestedValue ? Object(_utils__WEBPACK_IMPORTED_MODULE_1__["getNestedProperty"])(Object(pathington__WEBPACK_IMPORTED_MODULE_0__["parse"])(path), value) : value;
};
};
var identity = createIdentity(0);
var identitySecond = createIdentity(1);
var identityLast = createIdentity(-1);
var identitySecondLast = createIdentity(-2);
/***/ }),
/***/ "./src/utils.js":
/*!**********************!*\
!*** ./src/utils.js ***!
\**********************/
/*! exports provided: getNestedProperty */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNestedProperty", function() { return getNestedProperty; });
/**
* @function getNestedProperty

@@ -341,13 +443,13 @@ *

if (path.length === 1) {
return object ? object[path[0]] : undefined;
return object ? object[path[0]] : void 0;
}
var property = path.shift();
return object && object.hasOwnProperty(property) ? getNestedProperty(path, object[property]) : undefined;
return object && object.hasOwnProperty(property) ? getNestedProperty(path, object[property]) : void 0;
};
/***/ })
/******/ ]);
/******/ });
});
//# sourceMappingURL=identitate.js.map

@@ -1,1 +0,1 @@

!(function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("identitate",[],e):"object"==typeof exports?exports.identitate=e():t.identitate=e()})("undefined"!=typeof self?self:this,(function(){return (function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)})([(function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=/\w+|"[^"]+"/g,o=/['|"|`]/,i=new RegExp((""+o).slice(1,-1),"g"),u=function(t){return o.test(t[0])&&t[0]===t[t.length-1]},f=function(t){return u(t)?t.slice(1,-1):isNaN(+t)?t:+t},c=function(t){return Array.isArray(t)?t.map(f):"string"==typeof t?t?t.replace(i,'"').match(r).map(f):[]:[t]},a=function t(e,n){if(1===e.length)return n?n[e[0]]:void 0;var r=e.shift();return n&&n.hasOwnProperty(r)?t(e,n[r]):void 0};n.d(e,"createIdentity",(function(){return d})),n.d(e,"identity",(function(){return s})),n.d(e,"identitySecond",(function(){return p})),n.d(e,"identityLast",(function(){return l})),n.d(e,"identitySecondLast",(function(){return y}));var d=function(t,e){var n=void 0!==e;return function(){for(var r=arguments.length,o=Array(r),i=0;i<r;i++)o[i]=arguments[i];var u=o[t<0?o.length+t:t];return n?a(c(e),u):u}},s=d(0),p=d(1),l=d(-1),y=d(-2)})])}));
!(function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("identitate",[],e):"object"==typeof exports?exports.identitate=e():t.identitate=e()})(window,(function(){return (function(t){var e={};function n(r){if(e[r])return e[r].exports;var u=e[r]={i:r,l:!1,exports:{}};return t[r].call(u.exports,u,u.exports,n),u.l=!0,u.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var u in t)n.d(r,u,function(e){return t[e]}.bind(null,u));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)})([(function(t,e,n){"use strict";n.r(e);var r={clear:function(){r.results={},r.size=0},results:{},size:0},u=/"[^"]+"|`[^`]+`|'[^']+'|[^.[\]]+/g,o=/^\d+$/i,i=/^"[^"]+"|`[^`]+`|'[^']+'$/,f=function(t){return!!t.length&&o.test(t)},c=function(t){return i.test(t)},s=function(t){var e=c(t)?t.substring(1,t.length-1):t;return f(e)?+e:e},d=function(t){return"string"==typeof t?(function(t){return r.results[t]?r.results[t]:(r.size>500&&r.clear(),r.results[t]=t?t.match(u).map(s):[t],r.size++,r.results[t])})(t):Array.isArray(t)?t.map(s):["number"==typeof t?t:""+t]};n.d(e,"createIdentity",(function(){return a})),n.d(e,"identity",(function(){return l})),n.d(e,"identitySecond",(function(){return p})),n.d(e,"identityLast",(function(){return y})),n.d(e,"identitySecondLast",(function(){return b}));var a=function(t,e){var n=void 0!==e;return function(){var r=arguments[t<0?arguments.length+t:t];return n?(function t(e,n){if(1===e.length)return n?n[e[0]]:void 0;var r=e.shift();return n&&n.hasOwnProperty(r)?t(e,n[r]):void 0})(d(e),r):r}},l=a(0),p=a(1),y=a(-1),b=a(-2)})])}));
// external dependencies
import { parse } from 'pathington';
import { parse } from 'pathington'; // utils
// utils
import { getNestedProperty } from './utils';
/**

@@ -17,16 +15,11 @@ * @function createIdentity

*/
export var createIdentity = function createIdentity(argIndex, path) {
var shouldGetNestedValue = path !== void 0;
return function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var value = args[argIndex < 0 ? args.length + argIndex : argIndex];
// eslint-disable-next-line prefer-rest-params
var value = arguments[argIndex < 0 ? arguments.length + argIndex : argIndex];
return shouldGetNestedValue ? getNestedProperty(parse(path), value) : value;
};
};
export var identity = createIdentity(0);

@@ -33,0 +26,0 @@ export var identitySecond = createIdentity(1);

@@ -13,8 +13,7 @@ /**

if (path.length === 1) {
return object ? object[path[0]] : undefined;
return object ? object[path[0]] : void 0;
}
var property = path.shift();
return object && object.hasOwnProperty(property) ? getNestedProperty(path, object[property]) : undefined;
return object && object.hasOwnProperty(property) ? getNestedProperty(path, object[property]) : void 0;
};

@@ -1,10 +0,13 @@

'use strict';
"use strict";
exports.__esModule = true;
exports.identitySecondLast = exports.identityLast = exports.identitySecond = exports.identity = exports.createIdentity = undefined;
exports.identitySecondLast = exports.identityLast = exports.identitySecond = exports.identity = exports.createIdentity = void 0;
var _pathington = require('pathington');
var _pathington = require("pathington");
var _utils = require('./utils');
var _utils = require("./utils");
// external dependencies
// utils
/**

@@ -20,13 +23,7 @@ * @function createIdentity

*/
// external dependencies
var createIdentity = exports.createIdentity = function createIdentity(argIndex, path) {
var createIdentity = function createIdentity(argIndex, path) {
var shouldGetNestedValue = path !== void 0;
return function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var value = args[argIndex < 0 ? args.length + argIndex : argIndex];
// eslint-disable-next-line prefer-rest-params
var value = arguments[argIndex < 0 ? arguments.length + argIndex : argIndex];
return shouldGetNestedValue ? (0, _utils.getNestedProperty)((0, _pathington.parse)(path), value) : value;

@@ -36,6 +33,10 @@ };

// utils
var identity = exports.identity = createIdentity(0);
var identitySecond = exports.identitySecond = createIdentity(1);
var identityLast = exports.identityLast = createIdentity(-1);
var identitySecondLast = exports.identitySecondLast = createIdentity(-2);
exports.createIdentity = createIdentity;
var identity = createIdentity(0);
exports.identity = identity;
var identitySecond = createIdentity(1);
exports.identitySecond = identitySecond;
var identityLast = createIdentity(-1);
exports.identityLast = identityLast;
var identitySecondLast = createIdentity(-2);
exports.identitySecondLast = identitySecondLast;
"use strict";
exports.__esModule = true;
exports.getNestedProperty = void 0;
/**

@@ -14,10 +16,11 @@ * @function getNestedProperty

*/
var getNestedProperty = exports.getNestedProperty = function getNestedProperty(path, object) {
var getNestedProperty = function getNestedProperty(path, object) {
if (path.length === 1) {
return object ? object[path[0]] : undefined;
return object ? object[path[0]] : void 0;
}
var property = path.shift();
return object && object.hasOwnProperty(property) ? getNestedProperty(path, object[property]) : void 0;
};
return object && object.hasOwnProperty(property) ? getNestedProperty(path, object[property]) : undefined;
};
exports.getNestedProperty = getNestedProperty;

@@ -5,12 +5,31 @@ {

"babel": {
"babelrc": true,
"presets": ["react"]
"testOptions": {
"plugins": [
"@babel/plugin-proposal-class-properties"
],
"presets": [
"@babel/react"
]
}
},
"failFast": true,
"files": ["test/*.js"],
"require": ["babel-register"],
"source": ["src/*.js"],
"files": [
"test/*.js"
],
"require": [
"@babel/register"
],
"sources": [
"src/*.js"
],
"verbose": true
},
"browserslist": ["defaults", "Explorer >= 9", "Safari >= 6", "Opera >= 15", "iOS >= 8", "Android >= 4"],
"browserslist": [
"defaults",
"Explorer >= 9",
"Safari >= 6",
"Opera >= 15",
"iOS >= 8",
"Android >= 4"
],
"bugs": {

@@ -24,25 +43,30 @@ "url": "https://github.com/planttheidea/identitate/issues"

"devDependencies": {
"ava": "^0.24.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^8.0.3",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.26.0",
"eslint": "^4.13.1",
"eslint-config-rapid7": "^2.11.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.9.0",
"html-webpack-plugin": "^2.30.1",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"ava": "^1.0.1",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.5",
"eslint": "^5.12.0",
"eslint-config-rapid7": "^3.1.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.1",
"html-webpack-plugin": "^3.2.0",
"in-publish": "^2.0.0",
"nyc": "^11.3.0",
"nyc": "^13.1.0",
"optimize-js-plugin": "^0.0.4",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"sinon": "^4.1.3",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.9.7"
"react": "^16.7.0",
"react-dom": "^16.7.0",
"sinon": "^7.2.2",
"webpack": "^4.28.3",
"webpack-cli": "^3.2.0",
"webpack-dev-server": "^3.1.14"
},
"keywords": ["identity", "compose"],
"keywords": [
"identity",
"compose"
],
"license": "MIT",

@@ -69,4 +93,3 @@ "homepage": "https://github.com/planttheidea/identitate#readme",

"prepublish": "if in-publish; then npm run prepublish:compile; fi",
"prepublish:compile":
"npm run lint && npm run test:coverage && npm run transpile:lib && npm run transpile:es && npm run dist",
"prepublish:compile": "npm run lint && npm run test:coverage && npm run transpile:lib && npm run transpile:es && npm run dist",
"start": "npm run dev",

@@ -79,3 +102,3 @@ "test": "NODE_PATH=. NODE_ENV=production BABEL_ENV=test ava",

},
"version": "1.0.0"
"version": "1.0.1"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc