New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

json-crawl

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-crawl - npm Package Compare versions

Comparing version 0.4.2 to 0.5.0

6

dist/clone.d.ts

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

import { CloneHook, CrawlParams, SyncCloneHook } from "./types";
export declare const clone: <T extends {}, R extends {} = {}>(data: any, hooks?: CloneHook<T, R> | CloneHook<T, R>[], params?: CrawlParams<T, R>) => Promise<any>;
export declare const syncClone: <T extends {}, R extends {} = {}>(data: any, hooks?: SyncCloneHook<T, R> | SyncCloneHook<T, R>[], params?: CrawlParams<T, R>) => any;
import type { CloneHook, CrawlParams, SyncCloneHook } from "./types";
export declare const clone: <T extends {}, R extends {} = {}>(data: unknown, hooks?: CloneHook<T, R> | CloneHook<T, R>[], params?: CrawlParams<T, R>) => Promise<any>;
export declare const syncClone: <T extends {}, R extends {} = {}>(data: unknown, hooks?: SyncCloneHook<T, R> | SyncCloneHook<T, R>[], params?: CrawlParams<T, R>) => any;
/*!
* json-crawl v0.4.2
* json-crawl v0.5.0
* Copyright (C) 2012-2023 Damir Yusipov
* Date: Wed, 13 Dec 2023 19:13:27 GMT
* Date: Mon, 25 Dec 2023 15:23:34 GMT
*/
var JsonCrawl=function(e){"use strict";function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(n[o[s]]=e[o[s]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(s,a){function r(e){try{u(o.next(e))}catch(e){a(e)}}function l(e){try{u(o.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,l)}u((o=o.apply(e,t||[])).next())}))}const o=(e={},t,n,o)=>{const s=`/${t}`,a="function"==typeof e["/**"]?e["/**"]({key:t,path:n,value:o}):e["/**"],r="function"==typeof e["/*"]?e["/*"]({key:t,path:n,value:o}):e["/*"];let l={};if(s in e)l=e[s];else if(!a&&!r)return;return l="function"==typeof l?l({key:t,path:n,value:o}):l,r&&(l=Object.assign(Object.assign({},r),l)),a?Object.assign(Object.assign({"/**":e["/**"]},a),l):l},s=e=>{const t={},n=e.reduce(((e,t)=>(Object.keys(t).forEach((t=>e.add(t))),e)),new Set);for(const o of n.keys()){const n=e.filter((e=>o in e));if(1!==n.length){if("/"!==o.charAt(0))throw new Error(`Cannot merge rules. Duplicate key: ${o}. Rules should not have same Rule key`);t[o]=(e,t)=>{const a=n.map((n=>"function"==typeof n[o]?n[o](e,t):n[o]));return s(a)}}else t[o]=n[0][o]}return t},a=e=>"object"==typeof e&&null!==e,r=e=>Array.isArray(e),l=(e,l,u={})=>n(void 0,void 0,void 0,(function*(){var n,i;l=r(l)?l:[l];const c=r(u.rules)?s(u.rules):u.rules,d=[{data:e,state:u.state,path:[],keys:[],keyIndex:-1,rules:c}];for(;d.length>0;){const e=d[d.length-1];if(e.keyIndex>=e.keys.length){for(;null===(n=e.hooks)||void 0===n?void 0:n.length;)e.hooks.pop()();d.pop();continue}const s=e.keys[e.keyIndex++],[u,y,f]=d.length>1?[e.data[s],[...e.path,s],o(e.rules,s,[...e.path,s],e.data[s])]:[e.data,e.path,c];let p={value:u,path:y,key:s,state:e.state,rules:f};const v=[];for(const e of l){if(!e||"function"!=typeof e)continue;const n=null!==(i=yield e(p))&&void 0!==i?i:{},{terminate:o,done:s,exitHook:a}=n,r=t(n,["terminate","done","exitHook"]);if(o)return;if(p=Object.assign(Object.assign({},p),r),a&&v.push(a),s){p=null;break}}if(p&&a(p.value)){const e=r(p.value)?[...p.value.keys()]:Object.keys(p.value);d.push({hooks:v,state:p.state,data:p.value,path:y,keys:e,keyIndex:0,rules:p.rules})}else for(;v.length;)v.pop()()}})),u=(e,n,l={})=>{var u,i;n=r(n)?n:[n];const c=r(l.rules)?s(l.rules):l.rules,d=[{data:e,state:l.state,path:[],keys:[],keyIndex:-1,rules:c}];for(;d.length>0;){const e=d[d.length-1];if(e.keyIndex>=e.keys.length){for(;null===(u=e.hooks)||void 0===u?void 0:u.length;)e.hooks.pop()();d.pop();continue}const s=e.keys[e.keyIndex++],[l,y,f]=d.length>1?[e.data[s],[...e.path,s],o(e.rules,s,[...e.path,s],e.data[s])]:[e.data,e.path,c];let p={value:l,path:y,key:s,state:e.state,rules:f};const v=[];for(const e of n){if(!e||"function"!=typeof e)continue;const n=null!==(i=e(p))&&void 0!==i?i:{},{terminate:o,done:s,exitHook:a}=n,r=t(n,["terminate","done","exitHook"]);if(o)return;if(a&&v.push(a),p=Object.assign(Object.assign({},p),r),s){p=null;break}}if(p&&a(p.value)){const e=r(p.value)?[...p.value.keys()]:Object.keys(p.value);d.push({hooks:v,state:p.state,data:p.value,path:y,keys:e,keyIndex:0,rules:p.rules})}else for(;v.length;)v.pop()()}};return e.clone=(e,t=[],o={})=>n(void 0,void 0,void 0,(function*(){t=Array.isArray(t)?t:[t];const s={},r=Object.assign({state:Object.assign(Object.assign({},o.state),{root:s,node:s})},o.rules?{rules:o.rules}:{});return yield l(e,[...t,({value:e,path:t,key:o,state:s})=>n(void 0,void 0,void 0,(function*(){return o=t.length?o:"#",s.node[o]=a(e)?Array.isArray(e)?[]:{}:e,{value:e,state:Object.assign(Object.assign({},s),{node:s.node[o]})}}))],r),s["#"]})),e.crawl=l,e.equal=(e,t)=>{if(e===t)return!0;let n=!0;return u(e,(({value:e,key:t,state:o})=>{const s=void 0===t?o.value:o.value[t],a={state:{value:s}};if(e===s)return a;if(n=!1,typeof e!=typeof s)return{done:!0};if(r(e)&&e.length!==s.length)return{terminate:!0};if("object"==typeof e&&null!==e){const t=Object.keys(e),n=Object.keys(s);if(t.length!==n.length||!t.every((e=>n.includes(e))))return{terminate:!0}}else if(e!==s)return{terminate:!0};return n=!0,a}),{state:{value:t}}),n},e.getNodeRules=o,e.isArray=r,e.isObject=a,e.mergeRules=s,e.syncClone=(e,t=[],n={})=>{t=Array.isArray(t)?t:[t];const o={},s=Object.assign({state:Object.assign(Object.assign({},n.state),{root:o,node:o})},n.rules?{rules:n.rules}:{});return u(e,[...t,({value:e,path:t,key:n,state:o})=>(n=t.length?n:"#",o.node[n]=a(e)?Array.isArray(e)?[]:{}:e,{value:e,state:Object.assign(Object.assign({},o),{node:o.node[n]})})],s),o["#"]},e.syncCrawl=u,e.transform=(e,t=[],o={})=>n(void 0,void 0,void 0,(function*(){t=r(t)?t:[t];const s={"#":e},u=Object.assign({state:Object.assign(Object.assign({},o.state),{root:s,node:s})},o.rules?{rules:o.rules}:{});return yield l(e,[...t,({value:e,path:t,key:o,state:s})=>n(void 0,void 0,void 0,(function*(){return o=t.length?o:"#",void 0===e?r(s.node)&&"number"==typeof o?s.node.splice(o,1):a(s.node)&&o in s.node&&delete s.node[o]:a(s.node)&&(s.node[o]=e),{value:e,state:s}}))],u),s["#"]})),Object.defineProperty(e,"__esModule",{value:!0}),e}({});
var JsonCrawl=function(e){"use strict";function t(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(n[o[s]]=e[o[s]])}return n}function n(e,t,n,o){return new(n||(n=Promise))((function(s,a){function r(e){try{u(o.next(e))}catch(e){a(e)}}function l(e){try{u(o.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,l)}u((o=o.apply(e,t||[])).next())}))}const o=(e={},t,n,o)=>{const s=`/${t}`,a="function"==typeof e["/**"]?e["/**"]({key:t,path:n,value:o}):e["/**"],r="function"==typeof e["/*"]?e["/*"]({key:t,path:n,value:o}):e["/*"];let l={};if(s in e)l=e[s];else if(!a&&!r)return;return l="function"==typeof l?l({key:t,path:n,value:o}):l,r&&(l=Object.assign(Object.assign({},r),l)),a?Object.assign(Object.assign({"/**":e["/**"]},a),l):l},s=e=>{const t={},n=e.reduce(((e,t)=>(Object.keys(t).forEach((t=>e.add(t))),e)),new Set);for(const o of n.keys()){const n=e.filter((e=>o in e));if(1!==n.length){if("/"!==o.charAt(0))throw new Error(`Cannot merge rules. Duplicate key: ${o}. Rules should not have same Rule key`);t[o]=(e,t)=>{const a=n.map((n=>"function"==typeof n[o]?n[o](e,t):n[o]));return s(a)}}else t[o]=n[0][o]}return t},a=e=>"object"==typeof e&&null!==e,r=e=>Array.isArray(e),l=(e,l,u={})=>n(void 0,void 0,void 0,(function*(){var n,i;l=r(l)?l:[l];const c=r(u.rules)?s(u.rules):u.rules,d=[{data:e,state:u.state,path:[],keys:[],keyIndex:-1,rules:c}];for(;d.length>0;){const e=d[d.length-1];if(e.keyIndex>=e.keys.length){for(;null===(n=e.hooks)||void 0===n?void 0:n.length;)e.hooks.pop()();d.pop();continue}const s=e.keys[e.keyIndex++],[u,f,y]=d.length>1?[e.data[s],[...e.path,s],o(e.rules,s,[...e.path,s],e.data[s])]:[e.data,e.path,c];let v={value:u,path:f,key:s,state:e.state,rules:y};const p=[];for(const e of l){if(!e||"function"!=typeof e)continue;const n=null!==(i=yield e(v))&&void 0!==i?i:{},{terminate:o,done:s,exitHook:a}=n,r=t(n,["terminate","done","exitHook"]);if(o)return;if(v=Object.assign(Object.assign({},v),r),a&&p.push(a),s){v=null;break}}if(v&&a(v.value)){const e=r(v.value)?[...v.value.keys()]:Object.keys(v.value);d.push({hooks:p,state:v.state,data:v.value,path:f,keys:e,keyIndex:0,rules:v.rules})}else for(;p.length;)p.pop()()}})),u=(e,n,l={})=>{var u,i;n=r(n)?n:[n];const c=r(l.rules)?s(l.rules):l.rules,d=[{data:e,state:l.state,path:[],keys:[],keyIndex:-1,rules:c}];for(;d.length>0;){const e=d[d.length-1];if(e.keyIndex>=e.keys.length){for(;null===(u=e.hooks)||void 0===u?void 0:u.length;)e.hooks.pop()();d.pop();continue}const s=e.keys[e.keyIndex++],[l,f,y]=d.length>1?[e.data[s],[...e.path,s],o(e.rules,s,[...e.path,s],e.data[s])]:[e.data,e.path,c];let v={value:l,path:f,key:s,state:e.state,rules:y};const p=[];for(const e of n){if(!e||"function"!=typeof e)continue;const n=null!==(i=e(v))&&void 0!==i?i:{},{terminate:o,done:s,exitHook:a}=n,r=t(n,["terminate","done","exitHook"]);if(o)return;if(a&&p.push(a),v=Object.assign(Object.assign({},v),r),s){v=null;break}}if(v&&a(v.value)){const e=r(v.value)?[...v.value.keys()]:Object.keys(v.value);d.push({hooks:p,state:v.state,data:v.value,path:f,keys:e,keyIndex:0,rules:v.rules})}else for(;p.length;)p.pop()()}};return e.clone=(e,t=[],o={})=>n(void 0,void 0,void 0,(function*(){var s;t=Array.isArray(t)?t:[t];const r={},u=new WeakMap,i=Object.assign({state:Object.assign(Object.assign({},null!==(s=o.state)&&void 0!==s?s:{}),{root:r,node:r})},o.rules?{rules:o.rules}:{});return yield l(e,[...t,({value:e,path:t,key:o,state:s})=>n(void 0,void 0,void 0,(function*(){if(o=t.length?o:"#",a(e)){if(u.has(e))return s.node[o]=u.get(e),{done:!0};const t=Array.isArray(e)?[]:{};s.node[o]=t,u.set(e,t)}else s.node[o]=e;return{value:e,state:Object.assign(Object.assign({},s),{node:s.node[o]})}}))],i),r["#"]})),e.crawl=l,e.equal=(e,t)=>{if(e===t)return!0;let n=!0;return u(e,(({value:e,key:t,state:o})=>{const s=void 0===t?o.value:o.value[t],a={state:{value:s}};if(e===s)return a;if(n=!1,typeof e!=typeof s)return{done:!0};if(r(e)&&e.length!==s.length)return{terminate:!0};if("object"==typeof e&&null!==e){const t=Object.keys(e),n=Object.keys(s);if(t.length!==n.length||!t.every((e=>n.includes(e))))return{terminate:!0}}else if(e!==s)return{terminate:!0};return n=!0,a}),{state:{value:t}}),n},e.getNodeRules=o,e.isArray=r,e.isObject=a,e.mergeRules=s,e.syncClone=(e,t=[],n={})=>{var o;t=Array.isArray(t)?t:[t];const s={},r=new WeakMap,l=Object.assign({state:Object.assign(Object.assign({},null!==(o=n.state)&&void 0!==o?o:{}),{root:s,node:s})},n.rules?{rules:n.rules}:{});return u(e,[...t,({value:e,path:t,key:n,state:o})=>{if(n=t.length?n:"#",a(e)){if(r.has(e))return o.node[n]=r.get(e),{done:!0};const t=Array.isArray(e)?[]:{};o.node[n]=t,r.set(e,t)}else o.node[n]=e;return{value:e,state:Object.assign(Object.assign({},o),{node:o.node[n]})}}],l),s["#"]},e.syncCrawl=u,e.transform=(e,t=[],o={})=>n(void 0,void 0,void 0,(function*(){t=r(t)?t:[t];const s={"#":e},u=Object.assign({state:Object.assign(Object.assign({},o.state),{root:s,node:s})},o.rules?{rules:o.rules}:{});return yield l(e,[...t,({value:e,path:t,key:o,state:s})=>n(void 0,void 0,void 0,(function*(){return o=t.length?o:"#",void 0===e?r(s.node)&&"number"==typeof o?s.node.splice(o,1):a(s.node)&&o in s.node&&delete s.node[o]:a(s.node)&&(s.node[o]=e),{value:e,state:s}}))],u),s["#"]})),Object.defineProperty(e,"__esModule",{value:!0}),e}({});
//# sourceMappingURL=index.iife.js.map

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

import { CrawlRules, JsonPath } from "./types";
import type { CrawlRules, JsonPath } from "./types";
export declare const getNodeRules: <R extends {} = {}>(rules: CrawlRules<R> | undefined, key: string | number, path: JsonPath, value: unknown) => CrawlRules<R> | undefined;
export declare const mergeRules: <T extends {}, R extends {} = {}>(rules: CrawlRules<R>[]) => CrawlRules<R>;
{
"name": "json-crawl",
"version": "0.4.2",
"version": "0.5.0",
"description": "Async and sync crawler for json object",

@@ -5,0 +5,0 @@ "type": "commonjs",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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