Socket
Socket
Sign inDemoInstall

@blakek/deep

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blakek/deep - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0

dist/index.esm.js.map

22

dist/index.d.ts

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

export declare type Path = Array<number | string> | string;
export declare type ObjectLike = Record<keyof unknown, unknown>;
export declare type WithProperties = ObjectLike | unknown[];
export declare type Path = string | Array<string | number>;
export declare type ObjectLike = Record<string | number, any>;
export declare function isObject(object: unknown): object is ObjectLike;
export declare function clone<T extends unknown>(value: T): T;
export declare function traverseObject(object: any, path: string[]): any;
export declare const get: import("@blakek/curry").Curry2<Path, any, any>;
export declare const getOr: import("@blakek/curry").Curry3<any, Path, any, any>;
export declare const has: import("@blakek/curry").Curry2<Path, any, boolean>;
export declare const omit: import("@blakek/curry").Curry2<Path[], WithProperties, WithProperties>;
export declare const pluck: import("@blakek/curry").Curry2<Path[], any, any>;
export declare const remove: import("@blakek/curry").Curry2<Path, any, any>;
export declare const set: import("@blakek/curry").Curry3<any, Path, any, any>;
export declare function traverseObject(object: unknown, path: string[]): unknown;
export declare const get: import("@blakek/curry").Curry2<Path, ObjectLike, unknown>;
export declare const getOr: import("@blakek/curry").Curry3<unknown, Path, ObjectLike, unknown>;
export declare const has: import("@blakek/curry").Curry2<Path, ObjectLike, boolean>;
export declare const omit: import("@blakek/curry").Curry2<Path[], ObjectLike, ObjectLike>;
export declare const pluck: import("@blakek/curry").Curry2<Path[], ObjectLike, unknown>;
export declare const remove: import("@blakek/curry").Curry2<Path, any, Partial<any>>;
export declare const set: import("@blakek/curry").Curry3<unknown, Path, ObjectLike, ObjectLike>;

@@ -1,138 +0,2 @@

import { curry } from '@blakek/curry';
import { parse } from 'pathington';
function isObject(object) {
if (object === null) return false;
const type = typeof object;
return type === 'object' || type === 'function';
}
const NotFound = Symbol('curriable placeholder');
function clone(value) {
if (value instanceof Date) {
return new Date(value.getTime());
}
if (value instanceof Map) {
const result = new Map();
value.forEach((value, key) => {
result.set(key, clone(value));
});
return result;
}
if (value instanceof RegExp) {
return new RegExp(value.source, value.flags);
}
if (value instanceof Set) {
const result = new Set();
value.forEach(x => {
result.add(clone(x));
});
return result;
}
if (typeof value === 'object') {
if (value === null) {
return null;
}
const result = Array.isArray(value) ? [] : {};
for (const key in value) {
result[key] = clone(value[key]);
}
return result;
}
return value;
}
function traverseObject(object, path) {
// If the path has been exhausted, return the current object
if (path.length === 0) {
return object;
} // If the value could not be found, return `defaultValue`
if (!isObject(object)) {
return NotFound;
}
const [key, ...keys] = path; // Search deeper in the object
if (key in object) {
return traverseObject(object[key], keys);
} // The key was not found in the object.
return NotFound;
}
function _getOr(defaultValue, path, object) {
if (path === undefined) return object;
const value = traverseObject(object, parse(path));
if (value === NotFound || value === undefined) {
return defaultValue;
}
return value;
}
const _get = (path, object) => _getOr(undefined, path, object);
function _has(path, object) {
const value = traverseObject(object, parse(path));
return value !== NotFound;
}
function _remove(path, object) {
if (path === undefined) return object;
const parsedPath = parse(path);
const referencePath = parsedPath.slice(0, -1);
const finalPath = parsedPath[parsedPath.length - 1];
const reference = traverseObject(object, parse(referencePath));
if (!reference) return object;
delete reference[finalPath];
return object;
}
function _omit(properties, object) {
const cloned = clone(object);
properties.forEach(property => remove(property, cloned));
return cloned;
}
function _pluck(properties, object) {
return properties.reduce((subset, property) => _set(_get(property, object), property, subset), {});
}
function _set(value, path, object) {
const parsedPath = parse(path);
let reference = object;
parsedPath.forEach((key, index) => {
if (index === parsedPath.length - 1) {
reference[key] = value;
return;
}
if (!isObject(reference[key])) {
reference[key] = {};
}
reference = reference[key];
});
return object;
}
const get = curry(_get);
const getOr = curry(_getOr);
const has = curry(_has);
const omit = curry(_omit);
const pluck = curry(_pluck);
const remove = curry(_remove);
const set = curry(_set);
export { clone, get, getOr, has, omit, pluck, remove, set, traverseObject };
import{curry as r}from"@blakek/curry";import{parse as n}from"pathington";var t=Symbol("curriable placeholder");function e(r){if(null===r)return!1;var n=typeof r;return"object"===n||"function"===n}function u(r){if(r instanceof Date)return new Date(r.getTime());if(r instanceof Map){var n=new Map;return r.forEach(function(r,t){n.set(t,u(r))}),n}if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(r instanceof Set){var t=new Set;return r.forEach(function(r){t.add(u(r))}),t}if("object"==typeof r){if(null===r)return null;var e=Array.isArray(r)?[]:{};for(var i in r)e[i]=u(r[i]);return e}return r}function i(r,n){if(0===n.length)return r;if(!e(r))return t;var u=n[0],o=n.slice(1);return u in r?i(r[u],o):t}function o(r,e,u){if(void 0===e)return u;var o=i(u,n(e));return o===t||void 0===o?r:o}var f=function(r,n){return o(void 0,r,n)};function a(r,t,u){var i=n(t),o=u;return i.forEach(function(n,t){t===i.length-1?o[n]=r:(e(o[n])||(o[n]={}),o=o[n])}),u}var c=r(f),l=r(o),v=r(function(r,e){return i(e,n(r))!==t}),p=r(function(r,n){var t=u(n);return r.forEach(function(r){return d(r,t)}),t}),s=r(function(r,n){return r.reduce(function(r,t){return a(f(t,n),t,r)},{})}),d=r(function(r,t){if(void 0===r)return t;var u=n(r),o=u.slice(0,-1),f=u[u.length-1],a=i(t,n(o));return e(a)&&delete a[f],t}),h=r(a);export{u as clone,c as get,l as getOr,v as has,e as isObject,p as omit,s as pluck,d as remove,h as set,i as traverseObject};
//# sourceMappingURL=index.esm.js.map

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).deep={})}(this,(function(e){"use strict";function n(e,n){return void 0===n&&(n=e.length),function r(){for(var t=arguments.length,u=new Array(t),i=0;i<t;i++)u[i]=arguments[i];return u.length>=n?e.apply(void 0,u.slice(0,n)):function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return r.apply(void 0,u.concat(n))}}}var r={clear:function(){r.results={},r.size=0},results:{},size:0},t=/"[^"]+"|`[^`]+`|'[^']+'|[^.[\]]+/g,u=/^\d+$/i,i=/^"[^"]+"|`[^`]+`|'[^']+'$/,o=function(e,n){for(var r=e.length,t=[],u=0;u<r;u++)t[u]=n(e[u]);return t},f=function(e){var n=function(e){return i.test(e)}(e)?e.slice(1,e.length-1):e;return function(e){return!(!e||!e.length)&&u.test(e)}(n)?+n:n},c=Array.isArray,a=function(e){if("string"==typeof e)return function(e){return r.results[e]||(r.size>500&&r.clear(),r.results[e]=e?o(e.match(t),f):[e],r.size++),r.results[e]}(e);if(c(e))return o(e,f);var n=f(e);return["number"==typeof n?n:""+n]};function l(e){if(null===e)return!1;var n=typeof e;return"object"===n||"function"===n}var s=Symbol("curriable placeholder");function v(e){if(e instanceof Date)return new Date(e.getTime());if(e instanceof Map){var n=new Map;return e.forEach((function(e,r){n.set(r,v(e))})),n}if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Set){var r=new Set;return e.forEach((function(e){r.add(v(e))})),r}if("object"==typeof e){if(null===e)return null;var t=Array.isArray(e)?[]:{};for(var u in e)t[u]=v(e[u]);return t}return e}function d(e,n){if(0===n.length)return e;if(!l(e))return s;var r=n[0],t=n.slice(1);return r in e?d(e[r],t):s}function p(e,n,r){if(void 0===n)return r;var t=d(r,a(n));return t===s||void 0===t?e:t}var g=function(e,n){return p(void 0,e,n)};function h(e,n,r){var t=a(n),u=r;return t.forEach((function(n,r){r!==t.length-1?(l(u[n])||(u[n]={}),u=u[n]):u[n]=e})),r}var y=n(g),b=n(p),m=n((function(e,n){return d(n,a(e))!==s})),w=n((function(e,n){var r=v(n);return e.forEach((function(e){return E(e,r)})),r})),A=n((function(e,n){return e.reduce((function(e,r){return h(g(r,n),r,e)}),{})})),E=n((function(e,n){if(void 0===e)return n;var r=a(e),t=r.slice(0,-1),u=r[r.length-1],i=d(n,a(t));return i?(delete i[u],n):n})),j=n(h);e.clone=v,e.get=y,e.getOr=b,e.has=m,e.omit=w,e.pluck=A,e.remove=E,e.set=j,e.traverseObject=d,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@blakek/curry"),require("pathington")):"function"==typeof define&&define.amd?define(["exports","@blakek/curry","pathington"],e):e((r||self).deep={},r.curry,r.pathington)}(this,function(r,e,n){var t=Symbol("curriable placeholder");function u(r){if(null===r)return!1;var e=typeof r;return"object"===e||"function"===e}function i(r){if(r instanceof Date)return new Date(r.getTime());if(r instanceof Map){var e=new Map;return r.forEach(function(r,n){e.set(n,i(r))}),e}if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(r instanceof Set){var n=new Set;return r.forEach(function(r){n.add(i(r))}),n}if("object"==typeof r){if(null===r)return null;var t=Array.isArray(r)?[]:{};for(var u in r)t[u]=i(r[u]);return t}return r}function o(r,e){if(0===e.length)return r;if(!u(r))return t;var n=e[0],i=e.slice(1);return n in r?o(r[n],i):t}function f(r,e,u){if(void 0===e)return u;var i=o(u,n.parse(e));return i===t||void 0===i?r:i}var c=function(r,e){return f(void 0,r,e)};function a(r,e,t){var i=n.parse(e),o=t;return i.forEach(function(e,n){n===i.length-1?o[e]=r:(u(o[e])||(o[e]={}),o=o[e])}),t}var l=e.curry(c),s=e.curry(f),p=e.curry(function(r,e){return o(e,n.parse(r))!==t}),d=e.curry(function(r,e){var n=i(e);return r.forEach(function(r){return y(r,n)}),n}),v=e.curry(function(r,e){return r.reduce(function(r,n){return a(c(n,e),n,r)},{})}),y=e.curry(function(r,e){if(void 0===r)return e;var t=n.parse(r),i=t.slice(0,-1),f=t[t.length-1],c=o(e,n.parse(i));return u(c)&&delete c[f],e}),h=e.curry(a);r.clone=i,r.get=l,r.getOr=s,r.has=p,r.isObject=u,r.omit=d,r.pluck=v,r.remove=y,r.set=h,r.traverseObject=o});
//# sourceMappingURL=index.umd.js.map
{
"name": "@blakek/deep",
"version": "2.2.0",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"browser": "dist/index.umd.js",
"version": "3.0.0",
"source": "src/index.ts",
"exports": "./dist/index.modern.js",
"main": "./dist/index.cjs.js",
"module": "./dist/index.esm.js",
"unpkg": "./dist/index.umd.js",
"browser": "./dist/index.umd.js",
"author": "Blake Knight <oss.ideas@gmail.com> (https://blakek.me/)",

@@ -58,35 +61,24 @@ "description": "🐡 Get, set, remove, and test for deeply nested properties",

"devDependencies": {
"@babel/core": "^7.14.3",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-transform-runtime": "^7.14.3",
"@babel/preset-env": "^7.14.4",
"@babel/preset-typescript": "^7.13.0",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"amper-scripts": "^1.0.0",
"ava": "^3.9.0",
"nodemon": "^2.0.7",
"amper-scripts": "^1.2.4",
"ava": "^3.15.0",
"microbundle": "^0.13.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.1",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"rollup": "^2.51.1",
"rollup-plugin-terser": "^7.0.2",
"ts-node": "^10.0.0",
"typescript": "^4.3.2"
"typescript": "^4.3.5"
},
"peerDependencies": {},
"scripts": {
"build": "run-s build:clean build:types build:js",
"build": "run-s build:clean build:compile",
"build:clean": "rimraf ./dist",
"build:types": "tsc --emitDeclarationOnly",
"build:js": "rollup -c",
"format-check": "amper-scripts format-check",
"format": "amper-scripts format-write",
"lint": "amper-scripts lint --config ./.eslintrc.js 'src/**/*.{js,ts,tsx}'",
"build:compile": "microbundle --globals '@blakek/curry=curry'",
"format-check": "amper-scripts format-check .",
"format": "amper-scripts format-write .",
"lint": "amper-scripts lint src",
"prepack": "yarn build",
"test": "ava"
"test": "ava",
"type-check": "tsc --noEmit",
"validate": "run-p format-check lint type-check"
}
}

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