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

@naturalcycles/js-lib

Package Overview
Dependencies
Maintainers
0
Versions
525
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@naturalcycles/js-lib - npm Package Compare versions

Comparing version 14.250.0 to 14.251.0

50

dist-esm/object/object.util.js

@@ -10,5 +10,5 @@ import { _isEmpty, _isObject } from '../is.util';

// Start as original object (mutable), DELETE properties that are not whitelisted
for (const prop of Object.keys(obj)) {
if (!props.includes(prop))
delete obj[prop];
for (const k of Object.keys(obj)) {
if (!props.includes(k))
delete obj[k];
}

@@ -19,5 +19,5 @@ return obj;

const r = {};
for (const prop of props) {
if (prop in obj)
r[prop] = obj[prop];
for (const k of props) {
if (k in obj)
r[k] = obj[k];
}

@@ -27,2 +27,15 @@ return r;

/**
* Sets all properties of an object except passed ones to `undefined`.
* This is a more performant alternative to `_pick` that does picking/deleting.
*/
export function _pickWithUndefined(obj, props, mutate = false) {
const r = mutate ? obj : { ...obj };
for (const k of Object.keys(r)) {
if (!props.includes(k)) {
r[k] = undefined;
}
}
return r;
}
/**
* Returns clone of `obj` with `props` omitted.

@@ -33,4 +46,4 @@ * Opposite of Pick.

if (mutate) {
for (const prop of props) {
delete obj[prop];
for (const k of props) {
delete obj[k];
}

@@ -40,5 +53,5 @@ return obj;

const r = {};
for (const prop of Object.keys(obj)) {
if (!props.includes(prop))
r[prop] = obj[prop];
for (const k of Object.keys(obj)) {
if (!props.includes(k))
r[k] = obj[k];
}

@@ -48,2 +61,13 @@ return r;

/**
* Sets all passed properties of an object to `undefined`.
* This is a more performant alternative to `_omit` that does picking/deleting.
*/
export function _omitWithUndefined(obj, props, mutate = false) {
const r = mutate ? obj : { ...obj };
for (const k of props) {
r[k] = undefined;
}
return r;
}
/**
* Returns object with filtered keys from `props` array.

@@ -58,4 +82,4 @@ * E.g:

const r = mutate ? obj : _deepCopy(obj);
for (const prop of props) {
_unset(r, prop);
for (const k of props) {
_unset(r, k);
}

@@ -62,0 +86,0 @@ return r;

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

import { _omit } from '../index';
/**

@@ -9,11 +8,15 @@ * Returns new object with keys sorder in the given order.

const r = {};
keyOrder.forEach(key => {
if (key in obj) {
r[key] = obj[key];
// First, go over ordered keys
for (const k of keyOrder) {
if (k in obj) {
r[k] = obj[k];
}
});
Object.entries(_omit(obj, keyOrder)).forEach(([k, v]) => {
}
// Second, go over all other keys
for (const [k, v] of Object.entries(obj)) {
if (keyOrder.includes(k))
continue;
r[k] = v;
});
}
return r;
}

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

import { _isObject } from '..';
/**

@@ -10,12 +9,10 @@ * based on: https://github.com/IndigoUnited/js-deep-sort-object

}
if (_isObject(o)) {
const out = {};
Object.keys(o)
.sort((a, b) => a.localeCompare(b))
.forEach(k => {
out[k] = _sortObjectDeep(o[k]);
});
return out;
if (o && typeof o === 'object') {
const r = {};
for (const k of Object.keys(o).sort((a, b) => a.localeCompare(b))) {
r[k] = _sortObjectDeep(o[k]);
}
return r;
}
return o;
}

@@ -8,2 +8,7 @@ import { AnyObject, KeyValueTuple, ObjectMapper, ObjectPredicate, Reviver, SKIP, ValueOf } from '../types';

/**
* Sets all properties of an object except passed ones to `undefined`.
* This is a more performant alternative to `_pick` that does picking/deleting.
*/
export declare function _pickWithUndefined<T extends AnyObject, K extends keyof T>(obj: T, props: readonly K[], mutate?: boolean): T;
/**
* Returns clone of `obj` with `props` omitted.

@@ -14,2 +19,7 @@ * Opposite of Pick.

/**
* Sets all passed properties of an object to `undefined`.
* This is a more performant alternative to `_omit` that does picking/deleting.
*/
export declare function _omitWithUndefined<T extends AnyObject, K extends keyof T>(obj: T, props: readonly K[], mutate?: boolean): T;
/**
* Returns object with filtered keys from `props` array.

@@ -16,0 +26,0 @@ * E.g:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._pick = _pick;
exports._pickWithUndefined = _pickWithUndefined;
exports._omit = _omit;
exports._omitWithUndefined = _omitWithUndefined;
exports._mask = _mask;

@@ -38,5 +40,5 @@ exports._filterFalsyValues = _filterFalsyValues;

// Start as original object (mutable), DELETE properties that are not whitelisted
for (const prop of Object.keys(obj)) {
if (!props.includes(prop))
delete obj[prop];
for (const k of Object.keys(obj)) {
if (!props.includes(k))
delete obj[k];
}

@@ -47,5 +49,5 @@ return obj;

const r = {};
for (const prop of props) {
if (prop in obj)
r[prop] = obj[prop];
for (const k of props) {
if (k in obj)
r[k] = obj[k];
}

@@ -55,2 +57,15 @@ return r;

/**
* Sets all properties of an object except passed ones to `undefined`.
* This is a more performant alternative to `_pick` that does picking/deleting.
*/
function _pickWithUndefined(obj, props, mutate = false) {
const r = mutate ? obj : { ...obj };
for (const k of Object.keys(r)) {
if (!props.includes(k)) {
r[k] = undefined;
}
}
return r;
}
/**
* Returns clone of `obj` with `props` omitted.

@@ -61,4 +76,4 @@ * Opposite of Pick.

if (mutate) {
for (const prop of props) {
delete obj[prop];
for (const k of props) {
delete obj[k];
}

@@ -68,5 +83,5 @@ return obj;

const r = {};
for (const prop of Object.keys(obj)) {
if (!props.includes(prop))
r[prop] = obj[prop];
for (const k of Object.keys(obj)) {
if (!props.includes(k))
r[k] = obj[k];
}

@@ -76,2 +91,13 @@ return r;

/**
* Sets all passed properties of an object to `undefined`.
* This is a more performant alternative to `_omit` that does picking/deleting.
*/
function _omitWithUndefined(obj, props, mutate = false) {
const r = mutate ? obj : { ...obj };
for (const k of props) {
r[k] = undefined;
}
return r;
}
/**
* Returns object with filtered keys from `props` array.

@@ -86,4 +112,4 @@ * E.g:

const r = mutate ? obj : _deepCopy(obj);
for (const prop of props) {
_unset(r, prop);
for (const k of props) {
_unset(r, k);
}

@@ -90,0 +116,0 @@ return r;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._sortObject = _sortObject;
const index_1 = require("../index");
/**

@@ -12,11 +11,15 @@ * Returns new object with keys sorder in the given order.

const r = {};
keyOrder.forEach(key => {
if (key in obj) {
r[key] = obj[key];
// First, go over ordered keys
for (const k of keyOrder) {
if (k in obj) {
r[k] = obj[k];
}
});
Object.entries((0, index_1._omit)(obj, keyOrder)).forEach(([k, v]) => {
}
// Second, go over all other keys
for (const [k, v] of Object.entries(obj)) {
if (keyOrder.includes(k))
continue;
r[k] = v;
});
}
return r;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._sortObjectDeep = _sortObjectDeep;
const __1 = require("..");
/**

@@ -13,12 +12,10 @@ * based on: https://github.com/IndigoUnited/js-deep-sort-object

}
if ((0, __1._isObject)(o)) {
const out = {};
Object.keys(o)
.sort((a, b) => a.localeCompare(b))
.forEach(k => {
out[k] = _sortObjectDeep(o[k]);
});
return out;
if (o && typeof o === 'object') {
const r = {};
for (const k of Object.keys(o).sort((a, b) => a.localeCompare(b))) {
r[k] = _sortObjectDeep(o[k]);
}
return r;
}
return o;
}
{
"name": "@naturalcycles/js-lib",
"version": "14.250.0",
"version": "14.251.0",
"scripts": {

@@ -5,0 +5,0 @@ "prepare": "husky",

@@ -24,4 +24,4 @@ import { _isEmpty, _isObject } from '../is.util'

// Start as original object (mutable), DELETE properties that are not whitelisted
for (const prop of Object.keys(obj)) {
if (!props.includes(prop as K)) delete obj[prop]
for (const k of Object.keys(obj)) {
if (!props.includes(k as K)) delete obj[k]
}

@@ -32,4 +32,4 @@ return obj

const r = {} as T
for (const prop of props) {
if (prop in obj) r[prop] = obj[prop]
for (const k of props) {
if (k in obj) r[k] = obj[k]
}

@@ -40,2 +40,20 @@ return r

/**
* Sets all properties of an object except passed ones to `undefined`.
* This is a more performant alternative to `_pick` that does picking/deleting.
*/
export function _pickWithUndefined<T extends AnyObject, K extends keyof T>(
obj: T,
props: readonly K[],
mutate = false,
): T {
const r: T = mutate ? obj : { ...obj }
for (const k of Object.keys(r)) {
if (!props.includes(k as K)) {
r[k as K] = undefined as any
}
}
return r
}
/**
* Returns clone of `obj` with `props` omitted.

@@ -50,4 +68,4 @@ * Opposite of Pick.

if (mutate) {
for (const prop of props) {
delete obj[prop]
for (const k of props) {
delete obj[k]
}

@@ -58,4 +76,4 @@ return obj

const r = {} as T
for (const prop of Object.keys(obj)) {
if (!props.includes(prop as K)) r[prop as K] = obj[prop]
for (const k of Object.keys(obj)) {
if (!props.includes(k as K)) r[k as K] = obj[k]
}

@@ -66,2 +84,18 @@ return r

/**
* Sets all passed properties of an object to `undefined`.
* This is a more performant alternative to `_omit` that does picking/deleting.
*/
export function _omitWithUndefined<T extends AnyObject, K extends keyof T>(
obj: T,
props: readonly K[],
mutate = false,
): T {
const r: T = mutate ? obj : { ...obj }
for (const k of props) {
r[k] = undefined as any
}
return r
}
/**
* Returns object with filtered keys from `props` array.

@@ -76,4 +110,4 @@ * E.g:

const r = mutate ? obj : _deepCopy(obj)
for (const prop of props) {
_unset(r, prop)
for (const k of props) {
_unset(r, k)
}

@@ -80,0 +114,0 @@ return r

import type { AnyObject } from '../index'
import { _omit } from '../index'

@@ -12,13 +11,16 @@ /**

keyOrder.forEach(key => {
if (key in obj) {
r[key] = obj[key]
// First, go over ordered keys
for (const k of keyOrder) {
if (k in obj) {
r[k] = obj[k]
}
})
}
Object.entries(_omit(obj, keyOrder)).forEach(([k, v]) => {
// Second, go over all other keys
for (const [k, v] of Object.entries(obj)) {
if (keyOrder.includes(k)) continue
r[k as keyof T] = v
})
}
return r
}

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

import { _isObject } from '..'
/**

@@ -12,12 +10,8 @@ * based on: https://github.com/IndigoUnited/js-deep-sort-object

if (_isObject(o)) {
const out = {} as T
Object.keys(o)
.sort((a, b) => a.localeCompare(b))
.forEach(k => {
out[k as keyof T] = _sortObjectDeep(o[k as keyof T])
})
return out
if (o && typeof o === 'object') {
const r = {} as T
for (const k of Object.keys(o).sort((a, b) => a.localeCompare(b)) as (keyof T)[]) {
r[k] = _sortObjectDeep(o[k])
}
return r
}

@@ -24,0 +18,0 @@

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