Socket
Socket
Sign inDemoInstall

entry-list

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

entry-list - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

dist/cjs/tsconfig.tsbuildinfo

7

dist/cjs/index.d.ts
declare type Entry = {
key: (string | symbol)[];
key: (string | number | symbol)[];
value: any;
};
export declare function entryList(value: unknown, prefix?: (string | symbol)[], result?: Entry[], references?: unknown[]): Entry[];
declare type Options = {
collectSymbol: boolean;
};
export declare function entryList(value: unknown, options?: Options): Entry[];
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.entryList = void 0;
const toString = Object.prototype.toString;
function getKeys(value) {
if (Array.isArray(value)) {
return Object.keys(value);
}
if (toString.call(value) === '[object Object]') {
return [
...Object.keys(value),
...Object.getOwnPropertySymbols(value)
];
}
return null;
}
function entryList(value, prefix = [], result = [], references = []) {
const keys = getKeys(value);
if (keys === null) {
result.push({ value, key: prefix });
}
else {
references.push(value);
for (let i = 0, len = keys.length; i < len; ++i) {
// NOTE: https://github.com/microsoft/TypeScript/issues/1863
function entryList(value, options = { collectSymbol: false }) {
const { collectSymbol } = options;
const getKeys = collectSymbol
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
function (value) {
return Array.isArray(value)
? Object.keys(value)
: Reflect.ownKeys(value);
}
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
function (value) {
return Object.keys(value);
};
const result = [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const references = new WeakSet();
const getEntries = function getEntries(value, prefix = []) {
if (value !== null && typeof value === 'object') {
references.add(value);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore 2345
const keys = getKeys(value);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const v = value[keys[i]];
if (references.includes(v)) {
result.push({
value: v,
key: [...prefix, keys[i]]
});
for (const key of keys) {
// NOTE: https://github.com/microsoft/TypeScript/issues/1863
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const v = value[key];
if (references.has(v)) {
result.push({
value: v,
key: [...prefix, key]
});
}
else {
getEntries(v, [...prefix, key]);
}
}
else {
entryList(v, [...prefix, keys[i]], result, references);
}
}
}
return result;
else {
result.push({ value, key: prefix });
}
return result;
};
return getEntries(value);
}
exports.entryList = entryList;
//# sourceMappingURL=index.js.map

@@ -12,38 +12,46 @@ /*!

const toString = Object.prototype.toString;
function getKeys(value) {
if (Array.isArray(value)) {
return Object.keys(value);
}
if (toString.call(value) === '[object Object]') {
return [
...Object.keys(value),
...Object.getOwnPropertySymbols(value)
];
}
return null;
}
function entryList(value, prefix = [], result = [], references = []) {
const keys = getKeys(value);
if (keys === null) {
result.push({ value, key: prefix });
}
else {
references.push(value);
for (let i = 0, len = keys.length; i < len; ++i) {
// NOTE: https://github.com/microsoft/TypeScript/issues/1863
function entryList(value, options = { collectSymbol: false }) {
const { collectSymbol } = options;
const getKeys = collectSymbol
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
function (value) {
return Array.isArray(value)
? Object.keys(value)
: Reflect.ownKeys(value);
}
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
function (value) {
return Object.keys(value);
};
const result = [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const references = new WeakSet();
const getEntries = function getEntries(value, prefix = []) {
if (value !== null && typeof value === 'object') {
references.add(value);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore 2345
const keys = getKeys(value);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const v = value[keys[i]];
if (references.includes(v)) {
result.push({
value: v,
key: [...prefix, keys[i]]
});
for (const key of keys) {
// NOTE: https://github.com/microsoft/TypeScript/issues/1863
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const v = value[key];
if (references.has(v)) {
result.push({
value: v,
key: [...prefix, key]
});
}
else {
getEntries(v, [...prefix, key]);
}
}
else {
entryList(v, [...prefix, keys[i]], result, references);
}
}
}
return result;
else {
result.push({ value, key: prefix });
}
return result;
};
return getEntries(value);
}

@@ -50,0 +58,0 @@

@@ -6,2 +6,2 @@ /*!

*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).entryList={})}(this,(function(e){"use strict";const t=Object.prototype.toString;e.entryList=function e(n,o=[],s=[],i=[]){const l=function(e){return Array.isArray(e)?Object.keys(e):"[object Object]"===t.call(e)?[...Object.keys(e),...Object.getOwnPropertySymbols(e)]:null}(n);if(null===l)s.push({value:n,key:o});else{i.push(n);for(let t=0,r=l.length;t<r;++t){const r=n[l[t]];i.includes(r)?s.push({value:r,key:[...o,l[t]]}):e(r,[...o,l[t]],s,i)}}return s},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).entryList={})}(this,(function(e){"use strict";e.entryList=function(e,t={collectSymbol:!1}){const{collectSymbol:n}=t,o=n?function(e){return Array.isArray(e)?Object.keys(e):Reflect.ownKeys(e)}:function(e){return Object.keys(e)},s=[],f=new WeakSet;return function e(t,n=[]){if(null!==t&&"object"==typeof t){f.add(t);const c=o(t);for(const o of c){const c=t[o];f.has(c)?s.push({value:c,key:[...n,o]}):e(c,[...n,o])}}else s.push({value:t,key:n});return s}(e)},Object.defineProperty(e,"__esModule",{value:!0})}));

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

# 0.1.1 / 2021-03-06
- optimize
# 0.1.0 / 2021-02-06
- initial release
{
"name": "entry-list",
"description": "get entry list of object",
"version": "0.1.0",
"version": "0.1.1",
"author": "sasa+1 <sasaplus1@gmail.com>",

@@ -13,2 +13,3 @@ "browser": "./dist/umd/entry-list.js",

"@wessberg/rollup-plugin-ts": "^1.3.8",
"benchmark": "^2.1.4",
"eslint": "^7.19.0",

@@ -43,3 +44,4 @@ "eslint-config-prettier": "^7.2.0",

"scripts": {
"build": "run-s build:*",
"benchmark": "node ./benchmark/index.js",
"build": "run-p -l build:*",
"build:cjs": "tsc",

@@ -46,0 +48,0 @@ "build:mjs": "rollup -c --environment build:esm",

# entry-list.js
[![Actions Status: test](https://github.com/sasaplus1/entry-list.js/workflows/test/badge.svg)](https://github.com/sasaplus1/entry-list.js/actions?query=workflow%3A"test")
get entry list of object

@@ -4,0 +6,0 @@

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