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

@ctx-core/object

Package Overview
Dependencies
Maintainers
1
Versions
666
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ctx-core/object - npm Package Compare versions

Comparing version 4.2.2 to 5.0.0

184

lib.js

@@ -12,4 +12,4 @@ import { _andand } from '@ctx-core/function'

* @function assign
* @param {module:@ctx-core/object~ctx} ctx
* @param {...module:@ctx-core/object~ctx__assign} ctx__assign - Assigned to ctx
* @param {ctx} ctx
* @param {...ctx__assign} ctx__assign - Assigned to ctx
*/

@@ -29,3 +29,3 @@ export const assign = Object.assign.bind(Object)

* Returns string representation of an object. Alias to `Object.prototype.string`
* @type {() => string}
* @type {function(): string}
*/

@@ -58,4 +58,4 @@ export const toString = Object.prototype.toString

* Returns the [ctx](#ctx) with default values. If `ctx[key] == null`, use `default[key]`
* @param {module:@ctx-core/object~ctx}
* @param {...defaults$ctx} Default values to set on `ctx` if `ctx[key] == null`
* @param {ctx} ctx
* @param {...*} a1__defaults values to set on `ctx` if `ctx[key] == null`
* @returns {ctx}

@@ -72,4 +72,5 @@ */

* Assign only if ctx is not null
* @param {module:@ctx-core/object~ctx} ctx
* @returns {module:@ctx-core/object~ctx} ctx
* @param {ctx} ctx
* @param {...*} *
* @returns {ctx} ctx
*/

@@ -81,4 +82,4 @@ export function assign__unless__null(ctx) {

* Assigns [ctx__assign](#ctx__assign) to a new [ctx](#ctx).
* @param {...@ctx-core/object~ctx__assign} ctx__assign - Assigned to cloned `ctx`
* @returns {@ctx-core/object~ctx} ctx
* @param {...ctx__assign} * Assigned to cloned `ctx`
* @returns {ctx} ctx
*/

@@ -90,3 +91,3 @@ export function clone() {

* Performs a deep clone of the assigned arguments
* @returns {any}
* @returns {*}
*/

@@ -97,5 +98,5 @@ export function clone__deep() {

/**
* Mixin properties from sources into target
* Mixin properties from a1__source into target
* @param {Object} target
* @param {Object} sources
* @param {...*} a1__source
* @returns target

@@ -109,5 +110,5 @@ * @example

*/
export function mixin(target, ...sources) {
for (let i = 0; i < sources.length; i++) {
const source = sources[i]
export function mixin(target, ...a1__source) {
for (let i = 0; i < a1__source.length; i++) {
const source = a1__source[i]
const propertyNames = Object.getOwnPropertyNames(source)

@@ -127,3 +128,3 @@ for (let j = 0; j < propertyNames.length; j++) {

* @param target
* @param {...object} a1__source
* @param {...*} a1__source
* @returns target

@@ -150,9 +151,9 @@ */

/**
* Ensures that the keys in `a1__rest` are added to ctx
* Ensures that the keys in `a1__ctx__rest` are added to ctx
* only if the key is not defined on [ctx](#ctx) (== null).
* The order of precedence is from left to right.
* @param {ctx}
* @param {...a1__rest} a1__rest
* @param {ctx} ctx
* @param {...ctx} a1__ctx__rest
* Rest of key/value pairs to define if not defined on [ctx](#ctx)
* @returns {module:@ctx-core/object~ctx}
* @returns {ctx}
* @example

@@ -162,8 +163,8 @@ * ctx = {baz: 99}

*/
export function ensure(ctx, ...a1__rest) {
for (let i = 0; i < a1__rest.length; i++) {
const rest = a1__rest[i]
const keys__ctx__rest = keys(rest || {})
for (let j = 0; j < keys__ctx__rest.length; j++) {
const key = keys__ctx__rest[j]
export function ensure(ctx, ...a1__ctx__rest) {
for (let i = 0; i < a1__ctx__rest.length; i++) {
const rest = a1__ctx__rest[i]
const a1__key__ctx__rest = keys(rest || {})
for (let j = 0; j < a1__key__ctx__rest.length; j++) {
const key = a1__key__ctx__rest[j]
if (ctx[key] == null) {

@@ -178,4 +179,4 @@ ctx[key] = rest[key]

* New `obj` with only `a1__key`.
* @param {Object} obj
* @param {Array<string>} a1__key
* @param {*} obj
* @param {...string} a1__key
*/

@@ -186,2 +187,3 @@ export function pick(obj, ...a1__key) {

const key = a1__key[i]
memo[key] = obj[key]
if (obj.hasOwnProperty(key)) memo[key] = obj[key]

@@ -192,5 +194,19 @@ }

/**
* Returns object with picked values,
* not including including inherited property values (i.e. if hasOwnProperty is false).
* @param {ctx} ctx
* @param {...string} a1__key
*/
export function pick__hasOwnProperty(ctx, ...a1__key) {
let memo = {}
for (let i = 0; i < a1__key.length; i++) {
const key = a1__key[i]
if (ctx.hasOwnProperty(key)) memo[key] = ctx[key]
}
return memo
}
/**
* Does not include `a1__keys` from `obj`
* @param {Object} obj
* @param {Array<string>} a1__key
* @param {*} obj
* @param {...string} a1__key
*/

@@ -209,3 +225,3 @@ export function unpick(obj, ...a1__key) {

* @param {ctx} ctx
* @param {Object} obj__keys
* @param {*} obj__keys
*/

@@ -218,3 +234,3 @@ export function pick__keys(ctx, obj__keys) {

* @param {ctx} ctx
* @param {Object} obj__keys
* @param {*} obj__keys
*/

@@ -224,2 +240,8 @@ export function unpick__keys(ctx, obj__keys) {

}
/**
* Returns an array of objects with [pick](#pick) applied.
* @param {ctx} ctx
* @param {...string} a1__key
* @returns {*[]}
*/
export function _a1__value__pick(ctx, ...a1__key) {

@@ -233,29 +255,21 @@ let a1__value = []

}
export function pick__all(ctx, ...a1__key) {
let memo = {}
for (let i = 0; i < a1__key.length; i++) {
const key = a1__key[i]
memo[key] = ctx[key]
}
return memo
}
/**
* Exclude keys from obj
* @param obj
* @param keys
* @returns {{}}
* @param {...string} a1__key
* @returns {*}
*/
export function exclude(obj, ...keys) {
const $ = {}
const exclude = new Set(keys)
export function exclude(obj, ...a1__key) {
const __ = {}
const exclude = new Set(a1__key)
for (let key in obj) {
if (!exclude.has(key)) {
$[key] = obj[key]
__[key] = obj[key]
}
}
return $
return __
}
/**
* Compare function used by some to determine if some of the calls to some__compare(value, key) match.
* @function some__compare
* @typedef {function} some__compare
* @param {*} value - The value of the current key/value iteration.

@@ -281,11 +295,15 @@ * @param {string} key - The key of the current key/value iteration.

/**
* @typedef {ctx} ctx__ensure__refresh
* @param {string} key
* @param {function(ctx): *} ensure Called when `ctx[key]` is falsy.
* `ctx[key]` is set to the return value.
* @param {function(ctx, *)} refresh Called with the ensured value of `ctx[key]`.
*/
/**
* `ensure` `ctx[key]` is present or call `ctx__refresh.init`. Then call `ctx__refresh.refresh`.
*
* - if `!ctx[key]` `ctx__refresh.ensure(ctx)`
* - `ctx__refresh.refresh(ctx, ctx[key])`
* @param {module:@ctx-core/object~ctx} ctx
* @param {module:@ctx-core/object~ctx} ctx__refresh
* @param {function} ctx__refresh.ensure - Called when `ctx[key]` is falsy.
* `ctx[key]` is set to the return value.
* @param {function} ctx__refresh.refresh - Called with the ensured value of `ctx[key]`.
* - `a1__ctx__refresh.refresh(ctx, ctx[key])`
* @param {ctx} ctx
* @param {...ctx__ensure__refresh} a1__ctx__refresh
* @returns {*} The value of the ctx[key]

@@ -308,6 +326,6 @@ */

* return the `value` if not null or `value__or`
* @param {module:@ctx-core/object~ctx} ctx
* @param {ctx} ctx
* @param {*} ctx.value - if not null; ctx.value$ || ctx.value
* @param {*} ctx.value__or - if null; ctx.value__or
* @param {*} [ctx.value$] if not null; use optional value$ instead of value
* @param {*=} ctx.value__ if not null; use optional value$ instead of value
* @returns {value|value__or} `value` if not null or `value__or`

@@ -323,3 +341,3 @@ */

}
const symbol__no_key = Symbol('no_key')
const symbol__no_key_arg = Symbol('no_key_arg')
/**

@@ -332,4 +350,4 @@ * Returns true if obj has given key; false otherwise.

*/
export function has__key(obj, key = symbol__no_key) {
if (key === symbol__no_key) {
export function has__key(obj, key = symbol__no_key_arg) {
if (key === symbol__no_key_arg) {
for (let key__ in obj) {

@@ -346,6 +364,17 @@ return true

/**
* Returns true if obj has at least 1 key
* @param obj
* @returns {boolean}
*/
export function has__some__key(obj) {
for (let key__ in obj) {
return true
}
return false
}
/**
* Returns [ctx](#ctx) with keys in `a1__key` having `value__clear`.
* @param {Array} a1__key
* @param {string[]} a1__key
* @param value__clear
* @return {Object}
* @return {*}
*/

@@ -362,5 +391,5 @@ export function _ctx__clear(a1__key, value__clear) {

* Returns [ctx](#ctx) with zipped a1__value
* @param {Array} a1__key
* @param {Array} a1__value
* @returns {Object}
* @param {string[]} a1__key
* @param {*[]} a1__value
* @returns {*}
*/

@@ -388,6 +417,11 @@ export function _ctx__zip(a1__key, a1__value) {

/**
* @typedef {function} fn__map__obj
* @param {*} value
* @param (string} key
*/
/**
* Maps values in `obj` to `fn`, returning object with values returned by `fn`.
* @param obj
* @param {Function} fn
* @returns {Object}
* @param {fn__map__obj} fn
* @returns {*}
*/

@@ -404,4 +438,4 @@ export function map__obj(obj, fn) {

* @param obj
* @param {Array} a1__key
* @returns {Object}
* @param {...string} a1__key
* @returns {*}
*/

@@ -413,4 +447,4 @@ export function map__obj__andand(obj, ...a1__key) {

* Returns function to map `obj` to `fn` returning object with values.
* @param {Function} fn
* @returns {function({})}
* @param {fn__map__obj} fn
* @returns {function(*)}
*/

@@ -424,4 +458,4 @@ export function _map__obj(fn) {

* map `values` `andand` `a1__key` in `obj` to `fn`, returning object with values return by `fn`.
* @param a1__key
* @returns {function({})}
* @param {...string} a1__key
* @returns {function(*)}
*/

@@ -435,3 +469,3 @@ export function _map__obj__andand(...a1__key) {

* @param obj
* @returns {Array}
* @returns {*[]}
* @returns {Array<Array<key, value>>}

@@ -450,3 +484,3 @@ */

* @param {string} key
* @returns {}
* @returns {*}
*/

@@ -459,2 +493,2 @@ export function _hash__key__obj(obj, key) {

return by__key__obj
}
}
{
"name": "@ctx-core/object",
"version": "4.2.2",
"version": "5.0.0",
"description": "ctx-core object",

@@ -24,5 +24,5 @@ "main": "lib.js",

"dependencies": {
"@ctx-core/function": "^8.0.0"
"@ctx-core/function": "^8.0.1"
},
"gitHead": "f7727f13a4589bf974d44b3606a0eea59ad9b828"
"gitHead": "faf3deba5ee72fec8a41a4ad5631fd70083c66ac"
}
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