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

@roots/container

Package Overview
Dependencies
Maintainers
5
Versions
919
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@roots/container - npm Package Compare versions

Comparing version 4.7.0-next.11 to 5.0.0-next.0

323

lib/cjs/Container/Container.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Container = void 0;
const _ = require("lodash");
const tslib_1 = require("tslib");
const autobind_decorator_1 = require("autobind-decorator");
const _ = (0, tslib_1.__importStar)(require("lodash"));
/**
* Provides a simple chainable interface for working with collections of data
*
* @public
*/

@@ -11,2 +15,6 @@ class Container {

* Class constructor
*
* @param repository - Key-value data store
*
* @public
*/

@@ -16,5 +24,7 @@ constructor(repository) {

* Identifier
*
* @public
*/
this.ident = 'container';
this.setStore(repository ?? {});
this.setStore(repository !== null && repository !== void 0 ? repository : {});
}

@@ -28,2 +38,5 @@ /**

* ```
*
* @public
* @decorator `@bind`
*/

@@ -42,2 +55,5 @@ all() {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -55,8 +71,11 @@ setStore(repository) {

* ```
*
* @param values - Values to merge onto the container store
* @returns The container instance
*
* @public
* @decorator `@bind`
*/
mergeStore(values) {
this.setStore({
...this.all(),
...values,
});
this.setStore(Object.assign(Object.assign({}, this.all()), values));
return this;

@@ -72,2 +91,8 @@ }

* ```
*
* @param fn - Function to run on the repository
* @returns The transformed repository
*
* @public
* @decorator `@bind`
*/

@@ -78,4 +103,4 @@ transformStore(transformFn) {

/**
* Runs the entire {@link Repository} through the supplied fn and returns
* the transformed value. The transformed {@link Repository} replaces the
* Runs the entire {@link (Repository:interface) | Repository} through the supplied fn and returns
* the transformed value. The transformed {@link (Repository:interface) | Repository} replaces the
* original.

@@ -87,2 +112,5 @@ *

* ```
*
* @public
* @decorator `@bind`
*/

@@ -109,2 +137,5 @@ mutateStore(mutationFn) {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -115,3 +146,3 @@ get(key) {

/**
* Returns a {@link Repository} key and value as a tuple
* Returns a {@link (Repository:interface) | Repository} key and value as a tuple
*

@@ -130,2 +161,5 @@ * @remarks

* ```
*
* @public
* @decorator `@bind`
*/

@@ -146,3 +180,3 @@ getEntries(key) {

/**
* Merges object created from an array of tuples with the {@link Repository}.
* Merges object created from an array of tuples with the {@link (Repository:interface) | Repository}.
*

@@ -158,2 +192,5 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/

@@ -171,2 +208,5 @@ fromEntries(entries) {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -181,3 +221,3 @@ each(key, callFn) {

/**
* Calls a supplied function for every {@link Repository} value, passing
* Calls a supplied function for every {@link (Repository:interface) | Repository} value, passing
* the item's key and value as callback parameters.

@@ -189,2 +229,5 @@ *

* ```
*
* @public
* @decorator `@bind`
*/

@@ -204,3 +247,3 @@ every(fn) {

/**
* Gets a nested value from the {@link Repository}
* Gets a nested value from the {@link (Repository:interface) | Repository}
*

@@ -212,12 +255,12 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/
findKeyIn(key, ...searchItem) {
const parseInner = v => (!_.isArray(v) ? Object.entries(v) : v).reduce((a, [k, v]) => ({
...a,
[k]: v,
}), {});
const parseInner = v => (!_.isArray(v) ? Object.entries(v) : v).reduce((a, [k, v]) => (Object.assign(Object.assign({}, a), { [k]: v })), {});
return _.findKey(parseInner(this.get(key)), ...searchItem);
}
/**
* Returns an array of values of the enumerable properties of a {@link Repository} object
* Returns an array of values of the enumerable properties of a {@link (Repository:interface) | Repository} object
*

@@ -234,2 +277,5 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/

@@ -240,3 +286,3 @@ getValues(key) {

/**
* Returns an array of values of the enumerable keys of a {@link Repository} object
* Returns an array of values of the enumerable keys of a {@link (Repository:interface) | Repository} object
*

@@ -254,2 +300,5 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/

@@ -260,3 +309,3 @@ getKeys(key) {

/**
* Get a {@link Repository} item as a {@link Map}.
* Get a {@link (Repository:interface) | Repository} item as a {@link MapConstructor}.
*

@@ -278,2 +327,5 @@ * @remarks

* ```
*
* @public
* @decorator `@bind`
*/

@@ -288,6 +340,6 @@ getMap(key) {

];
return this.getEntries(key ?? null).reduce(...reducer);
return this.getEntries(key !== null && key !== void 0 ? key : null).reduce(...reducer);
}
/**
* Set a {@link Repository} value
* Set a {@link (Repository:interface) | Repository} value
*

@@ -298,2 +350,5 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/

@@ -314,2 +369,8 @@ set(key, value) {

* ```
*
* @param key - The key of the item to transform
* @param fn - The function to transform the item with
*
* @public
* @decorator `@bind`
*/

@@ -320,3 +381,3 @@ transform(key, mutationFn) {

/**
* Mutate a {@link Repository} item
* Mutate a {@link (Repository:interface) | Repository} item
*

@@ -327,2 +388,8 @@ * @example

* ```
*
* @param key - The key of the item to mutate
* @param mutationFn - The mutation function to run on the item
*
* @public
* @decorator `@bind`
*/

@@ -334,3 +401,3 @@ mutate(key, mutationFn) {

/**
* Merge a supplied value with an existing {@link Repository} value
* Merge a supplied value with an existing {@link (Repository:interface) | Repository} value
*

@@ -341,2 +408,8 @@ * @example

* ```
*
* @param key - The key of the item to merge
* @param value - The value to merge with the existing value
*
* @public
* @decorator `@bind`
*/

@@ -355,2 +428,5 @@ merge(key, value) {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -370,2 +446,5 @@ has(key) {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -384,2 +463,5 @@ remove(key) {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -397,2 +479,8 @@ is(key, value) {

* ```
*
* @param key - The key to check
* @returns True if the key's value is true
*
* @public
* @decorator `@bind`
*/

@@ -410,2 +498,8 @@ isTrue(key) {

* ```
*
* @param key - The key to check
* @returns True if the key's value is false
*
* @public
* @decorator `@bind`
*/

@@ -423,2 +517,8 @@ isFalse(key) {

* ```
*
* @param key - The key to check
* @returns True if the key is likely an object.
*
* @public
* @decorator `@bind`
*/

@@ -439,2 +539,8 @@ isIndexed(key) {

* ```
*
* @param key - The key to check
* @returns True if the value is an array
*
* @public
* @decorator `@bind`
*/

@@ -452,2 +558,8 @@ isArray(key) {

* ```
*
* @param key - The key to check
* @returns True if object is not an array
*
* @public
* @decorator `@bind`
*/

@@ -465,2 +577,8 @@ isNotArray(key) {

* ```
*
* @param key - The key to check
* @returns True if object is a string
*
* @public
* @decorator `@bind`
*/

@@ -471,3 +589,3 @@ isString(key) {

/**
* Return true if object is a string.
* Return true if object is not a string.
*

@@ -479,2 +597,8 @@ * @example

* ```
*
* @param key - The key to check
* @returns True if object is not a string
*
* @public
* @decorator `@bind`
*/

@@ -492,2 +616,8 @@ isNotString(key) {

* ```
*
* @param key - The key to check
* @returns True if object is a number
*
* @public
* @decorator `@bind`
*/

@@ -505,2 +635,8 @@ isNumber(key) {

* ```
*
* @param key - The key to check
* @returns True if object is not a number
*
* @public
* @decorator `@bind`
*/

@@ -518,2 +654,5 @@ isNotNumber(key) {

* ```
*
* @param key - The key to check
* @returns True if object is null
*/

@@ -531,2 +670,8 @@ isNull(key) {

* ```
*
* @param key - The key to check
* @returns True if object is not null
*
* @public
* @decorator `@bind`
*/

@@ -540,6 +685,13 @@ isNotNull(key) {

* @example
* True if container has a 'my-key' entry with a definite value.
*
* ```js
* container.isDefined('my-key')
* // True if container has a 'my-key' entry with a definite value.
* ```
*
* @param key - The key to check.
* @returns True if the key is defined.
*
* @public
* @decorator `@bind`
*/

@@ -550,3 +702,3 @@ isDefined(key) {

/**
* Return true if object is defined.
* Return true if object is not defined.
*

@@ -558,2 +710,8 @@ * @example

* ```
*
* @param key - The key to check.
* @returns True if the key is not defined.
*
* @public
* @decorator `@bind`
*/

@@ -570,3 +728,9 @@ isUndefined(key) {

* // True if object associated with 'my-key' is a fn.
* ````
* ```
*
* @param key - The key to check.
* @returns True if object is a function.
*
* @public
* @decorator `@bind`
*/

@@ -577,3 +741,108 @@ isFunction(key) {

}
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "all", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "setStore", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "mergeStore", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "transformStore", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "mutateStore", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "get", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "getEntries", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "fromEntries", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "each", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "every", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "findKeyIn", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "getValues", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "getKeys", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "getMap", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "set", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "transform", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "mutate", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "merge", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "has", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "remove", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "is", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isTrue", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isFalse", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isIndexed", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isArray", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isNotArray", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isString", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isNotString", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isNumber", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isNotNumber", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isNull", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isNotNull", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isDefined", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isUndefined", null);
(0, tslib_1.__decorate)([
autobind_decorator_1.boundMethod
], Container.prototype, "isFunction", null);
exports.Container = Container;
//# sourceMappingURL=Container.js.map

13

lib/cjs/index.js
"use strict";
// Copyright (c) Roots Foundation, LLC. All rights reserved.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Container = void 0;
/**
* `@roots/container` is a utility to make working with collections of data simple and chainable.
* The {@link @roots/container# | @roots/container} package provides
* a simple chainable interface for working with collections of data
*
* @packageDocumentation
* @packageDocumentation @betaDocumentation
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Container = void 0;
const Container_1 = require("./Container");
var Container_1 = require("./Container");
Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return Container_1.Container; } });
//# sourceMappingURL=index.js.map

@@ -0,4 +1,8 @@

import { __decorate } from "tslib";
import { boundMethod as bind } from 'autobind-decorator';
import * as _ from 'lodash';
/**
* Provides a simple chainable interface for working with collections of data
*
* @public
*/

@@ -8,2 +12,6 @@ export class Container {

* Class constructor
*
* @param repository - Key-value data store
*
* @public
*/

@@ -13,5 +21,7 @@ constructor(repository) {

* Identifier
*
* @public
*/
this.ident = 'container';
this.setStore(repository ?? {});
this.setStore(repository !== null && repository !== void 0 ? repository : {});
}

@@ -25,2 +35,5 @@ /**

* ```
*
* @public
* @decorator `@bind`
*/

@@ -39,2 +52,5 @@ all() {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -52,8 +68,11 @@ setStore(repository) {

* ```
*
* @param values - Values to merge onto the container store
* @returns The container instance
*
* @public
* @decorator `@bind`
*/
mergeStore(values) {
this.setStore({
...this.all(),
...values,
});
this.setStore(Object.assign(Object.assign({}, this.all()), values));
return this;

@@ -69,2 +88,8 @@ }

* ```
*
* @param fn - Function to run on the repository
* @returns The transformed repository
*
* @public
* @decorator `@bind`
*/

@@ -75,4 +100,4 @@ transformStore(transformFn) {

/**
* Runs the entire {@link Repository} through the supplied fn and returns
* the transformed value. The transformed {@link Repository} replaces the
* Runs the entire {@link (Repository:interface) | Repository} through the supplied fn and returns
* the transformed value. The transformed {@link (Repository:interface) | Repository} replaces the
* original.

@@ -84,2 +109,5 @@ *

* ```
*
* @public
* @decorator `@bind`
*/

@@ -106,2 +134,5 @@ mutateStore(mutationFn) {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -112,3 +143,3 @@ get(key) {

/**
* Returns a {@link Repository} key and value as a tuple
* Returns a {@link (Repository:interface) | Repository} key and value as a tuple
*

@@ -127,2 +158,5 @@ * @remarks

* ```
*
* @public
* @decorator `@bind`
*/

@@ -143,3 +177,3 @@ getEntries(key) {

/**
* Merges object created from an array of tuples with the {@link Repository}.
* Merges object created from an array of tuples with the {@link (Repository:interface) | Repository}.
*

@@ -155,2 +189,5 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/

@@ -168,2 +205,5 @@ fromEntries(entries) {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -178,3 +218,3 @@ each(key, callFn) {

/**
* Calls a supplied function for every {@link Repository} value, passing
* Calls a supplied function for every {@link (Repository:interface) | Repository} value, passing
* the item's key and value as callback parameters.

@@ -186,2 +226,5 @@ *

* ```
*
* @public
* @decorator `@bind`
*/

@@ -201,3 +244,3 @@ every(fn) {

/**
* Gets a nested value from the {@link Repository}
* Gets a nested value from the {@link (Repository:interface) | Repository}
*

@@ -209,12 +252,12 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/
findKeyIn(key, ...searchItem) {
const parseInner = v => (!_.isArray(v) ? Object.entries(v) : v).reduce((a, [k, v]) => ({
...a,
[k]: v,
}), {});
const parseInner = v => (!_.isArray(v) ? Object.entries(v) : v).reduce((a, [k, v]) => (Object.assign(Object.assign({}, a), { [k]: v })), {});
return _.findKey(parseInner(this.get(key)), ...searchItem);
}
/**
* Returns an array of values of the enumerable properties of a {@link Repository} object
* Returns an array of values of the enumerable properties of a {@link (Repository:interface) | Repository} object
*

@@ -231,2 +274,5 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/

@@ -237,3 +283,3 @@ getValues(key) {

/**
* Returns an array of values of the enumerable keys of a {@link Repository} object
* Returns an array of values of the enumerable keys of a {@link (Repository:interface) | Repository} object
*

@@ -251,2 +297,5 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/

@@ -257,3 +306,3 @@ getKeys(key) {

/**
* Get a {@link Repository} item as a {@link Map}.
* Get a {@link (Repository:interface) | Repository} item as a {@link MapConstructor}.
*

@@ -275,2 +324,5 @@ * @remarks

* ```
*
* @public
* @decorator `@bind`
*/

@@ -285,6 +337,6 @@ getMap(key) {

];
return this.getEntries(key ?? null).reduce(...reducer);
return this.getEntries(key !== null && key !== void 0 ? key : null).reduce(...reducer);
}
/**
* Set a {@link Repository} value
* Set a {@link (Repository:interface) | Repository} value
*

@@ -295,2 +347,5 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/

@@ -311,2 +366,8 @@ set(key, value) {

* ```
*
* @param key - The key of the item to transform
* @param fn - The function to transform the item with
*
* @public
* @decorator `@bind`
*/

@@ -317,3 +378,3 @@ transform(key, mutationFn) {

/**
* Mutate a {@link Repository} item
* Mutate a {@link (Repository:interface) | Repository} item
*

@@ -324,2 +385,8 @@ * @example

* ```
*
* @param key - The key of the item to mutate
* @param mutationFn - The mutation function to run on the item
*
* @public
* @decorator `@bind`
*/

@@ -331,3 +398,3 @@ mutate(key, mutationFn) {

/**
* Merge a supplied value with an existing {@link Repository} value
* Merge a supplied value with an existing {@link (Repository:interface) | Repository} value
*

@@ -338,2 +405,8 @@ * @example

* ```
*
* @param key - The key of the item to merge
* @param value - The value to merge with the existing value
*
* @public
* @decorator `@bind`
*/

@@ -352,2 +425,5 @@ merge(key, value) {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -367,2 +443,5 @@ has(key) {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -381,2 +460,5 @@ remove(key) {

* ```
*
* @public
* @decorator `@bind`
*/

@@ -394,2 +476,8 @@ is(key, value) {

* ```
*
* @param key - The key to check
* @returns True if the key's value is true
*
* @public
* @decorator `@bind`
*/

@@ -407,2 +495,8 @@ isTrue(key) {

* ```
*
* @param key - The key to check
* @returns True if the key's value is false
*
* @public
* @decorator `@bind`
*/

@@ -420,2 +514,8 @@ isFalse(key) {

* ```
*
* @param key - The key to check
* @returns True if the key is likely an object.
*
* @public
* @decorator `@bind`
*/

@@ -436,2 +536,8 @@ isIndexed(key) {

* ```
*
* @param key - The key to check
* @returns True if the value is an array
*
* @public
* @decorator `@bind`
*/

@@ -449,2 +555,8 @@ isArray(key) {

* ```
*
* @param key - The key to check
* @returns True if object is not an array
*
* @public
* @decorator `@bind`
*/

@@ -462,2 +574,8 @@ isNotArray(key) {

* ```
*
* @param key - The key to check
* @returns True if object is a string
*
* @public
* @decorator `@bind`
*/

@@ -468,3 +586,3 @@ isString(key) {

/**
* Return true if object is a string.
* Return true if object is not a string.
*

@@ -476,2 +594,8 @@ * @example

* ```
*
* @param key - The key to check
* @returns True if object is not a string
*
* @public
* @decorator `@bind`
*/

@@ -489,2 +613,8 @@ isNotString(key) {

* ```
*
* @param key - The key to check
* @returns True if object is a number
*
* @public
* @decorator `@bind`
*/

@@ -502,2 +632,8 @@ isNumber(key) {

* ```
*
* @param key - The key to check
* @returns True if object is not a number
*
* @public
* @decorator `@bind`
*/

@@ -515,2 +651,5 @@ isNotNumber(key) {

* ```
*
* @param key - The key to check
* @returns True if object is null
*/

@@ -528,2 +667,8 @@ isNull(key) {

* ```
*
* @param key - The key to check
* @returns True if object is not null
*
* @public
* @decorator `@bind`
*/

@@ -537,6 +682,13 @@ isNotNull(key) {

* @example
* True if container has a 'my-key' entry with a definite value.
*
* ```js
* container.isDefined('my-key')
* // True if container has a 'my-key' entry with a definite value.
* ```
*
* @param key - The key to check.
* @returns True if the key is defined.
*
* @public
* @decorator `@bind`
*/

@@ -547,3 +699,3 @@ isDefined(key) {

/**
* Return true if object is defined.
* Return true if object is not defined.
*

@@ -555,2 +707,8 @@ * @example

* ```
*
* @param key - The key to check.
* @returns True if the key is not defined.
*
* @public
* @decorator `@bind`
*/

@@ -567,3 +725,9 @@ isUndefined(key) {

* // True if object associated with 'my-key' is a fn.
* ````
* ```
*
* @param key - The key to check.
* @returns True if object is a function.
*
* @public
* @decorator `@bind`
*/

@@ -574,2 +738,107 @@ isFunction(key) {

}
__decorate([
bind
], Container.prototype, "all", null);
__decorate([
bind
], Container.prototype, "setStore", null);
__decorate([
bind
], Container.prototype, "mergeStore", null);
__decorate([
bind
], Container.prototype, "transformStore", null);
__decorate([
bind
], Container.prototype, "mutateStore", null);
__decorate([
bind
], Container.prototype, "get", null);
__decorate([
bind
], Container.prototype, "getEntries", null);
__decorate([
bind
], Container.prototype, "fromEntries", null);
__decorate([
bind
], Container.prototype, "each", null);
__decorate([
bind
], Container.prototype, "every", null);
__decorate([
bind
], Container.prototype, "findKeyIn", null);
__decorate([
bind
], Container.prototype, "getValues", null);
__decorate([
bind
], Container.prototype, "getKeys", null);
__decorate([
bind
], Container.prototype, "getMap", null);
__decorate([
bind
], Container.prototype, "set", null);
__decorate([
bind
], Container.prototype, "transform", null);
__decorate([
bind
], Container.prototype, "mutate", null);
__decorate([
bind
], Container.prototype, "merge", null);
__decorate([
bind
], Container.prototype, "has", null);
__decorate([
bind
], Container.prototype, "remove", null);
__decorate([
bind
], Container.prototype, "is", null);
__decorate([
bind
], Container.prototype, "isTrue", null);
__decorate([
bind
], Container.prototype, "isFalse", null);
__decorate([
bind
], Container.prototype, "isIndexed", null);
__decorate([
bind
], Container.prototype, "isArray", null);
__decorate([
bind
], Container.prototype, "isNotArray", null);
__decorate([
bind
], Container.prototype, "isString", null);
__decorate([
bind
], Container.prototype, "isNotString", null);
__decorate([
bind
], Container.prototype, "isNumber", null);
__decorate([
bind
], Container.prototype, "isNotNumber", null);
__decorate([
bind
], Container.prototype, "isNull", null);
__decorate([
bind
], Container.prototype, "isNotNull", null);
__decorate([
bind
], Container.prototype, "isDefined", null);
__decorate([
bind
], Container.prototype, "isUndefined", null);
__decorate([
bind
], Container.prototype, "isFunction", null);
//# sourceMappingURL=Container.js.map

@@ -0,8 +1,10 @@

// Copyright (c) Roots Foundation, LLC. All rights reserved.
// Licensed under the MIT license.
/**
* `@roots/container` is a utility to make working with collections of data simple and chainable.
* The {@link @roots/container# | @roots/container} package provides
* a simple chainable interface for working with collections of data
*
* @packageDocumentation
* @packageDocumentation @betaDocumentation
*/
import { Container } from './Container';
export { Container };
export { Container } from './Container';
//# sourceMappingURL=index.js.map
{
"name": "@roots/container",
"version": "4.7.0-next.11",
"version": "5.0.0-next.0",
"description": "Collections utility",

@@ -37,6 +37,4 @@ "homepage": "https://roots.io/bud",

"files": [
"docs/",
"lib/",
"types/",
"manifest.yml"
"types/"
],

@@ -69,10 +67,13 @@ "main": "./lib/cjs/index.js",

"devDependencies": {
"@types/jest": "27.0.2",
"@types/node": "15.14.1",
"type-fest": "2.0.0"
"jest": "27.2.5",
"type-fest": "2.5.0"
},
"dependencies": {
"autobind-decorator": "^2.4.0",
"lodash": "^4.17.21"
"lodash": "^4.17.21",
"tslib": "^2.3.1"
},
"stableVersion": "4.6.0"
}

@@ -5,2 +5,4 @@ import type { ValueOf } from 'type-fest';

* Provides a simple chainable interface for working with collections of data
*
* @public
*/

@@ -10,2 +12,4 @@ export declare class Container<I = any> {

* Identifier
*
* @public
*/

@@ -15,6 +19,14 @@ ident: string;

* The container store
*
* @public
*/
repository: any;
repository: {
[key: string]: any;
};
/**
* Class constructor
*
* @param repository - Key-value data store
*
* @public
*/

@@ -29,4 +41,9 @@ constructor(repository?: I);

* ```
*
* @public
* @decorator `@bind`
*/
all(): any;
all(): {
[key: string]: any;
};
/**

@@ -41,2 +58,5 @@ * Replace the store with an all new set of values

* ```
*
* @public
* @decorator `@bind`
*/

@@ -51,2 +71,8 @@ setStore(repository: Repository): this;

* ```
*
* @param values - Values to merge onto the container store
* @returns The container instance
*
* @public
* @decorator `@bind`
*/

@@ -62,7 +88,13 @@ mergeStore(values: Repository): this;

* ```
*
* @param fn - Function to run on the repository
* @returns The transformed repository
*
* @public
* @decorator `@bind`
*/
transformStore(transformFn: (value: any) => any): any;
/**
* Runs the entire {@link Repository} through the supplied fn and returns
* the transformed value. The transformed {@link Repository} replaces the
* Runs the entire {@link (Repository:interface) | Repository} through the supplied fn and returns
* the transformed value. The transformed {@link (Repository:interface) | Repository} replaces the
* original.

@@ -74,2 +106,5 @@ *

* ```
*
* @public
* @decorator `@bind`
*/

@@ -92,6 +127,9 @@ mutateStore(mutationFn: (value?: I) => I): this;

* ```
*
* @public
* @decorator `@bind`
*/
get<T = any>(key: string | number): T;
/**
* Returns a {@link Repository} key and value as a tuple
* Returns a {@link (Repository:interface) | Repository} key and value as a tuple
*

@@ -110,6 +148,9 @@ * @remarks

* ```
*
* @public
* @decorator `@bind`
*/
getEntries<T = any>(key?: string | number): [string, ValueOf<T>][];
/**
* Merges object created from an array of tuples with the {@link Repository}.
* Merges object created from an array of tuples with the {@link (Repository:interface) | Repository}.
*

@@ -125,2 +166,5 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/

@@ -135,6 +179,9 @@ fromEntries(entries: [string, any][]): this;

* ```
*
* @public
* @decorator `@bind`
*/
each(key: string | number, callFn: (key: any, value: any) => void): this;
/**
* Calls a supplied function for every {@link Repository} value, passing
* Calls a supplied function for every {@link (Repository:interface) | Repository} value, passing
* the item's key and value as callback parameters.

@@ -146,2 +193,5 @@ *

* ```
*
* @public
* @decorator `@bind`
*/

@@ -154,3 +204,3 @@ every(fn: (key: string | number, value: any) => any): this;

/**
* Gets a nested value from the {@link Repository}
* Gets a nested value from the {@link (Repository:interface) | Repository}
*

@@ -162,6 +212,9 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/
findKeyIn(key: string | number, ...searchItem: any[]): any;
/**
* Returns an array of values of the enumerable properties of a {@link Repository} object
* Returns an array of values of the enumerable properties of a {@link (Repository:interface) | Repository} object
*

@@ -178,6 +231,9 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/
getValues(key?: string): any[];
/**
* Returns an array of values of the enumerable keys of a {@link Repository} object
* Returns an array of values of the enumerable keys of a {@link (Repository:interface) | Repository} object
*

@@ -195,6 +251,9 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/
getKeys(key?: string): string[];
/**
* Get a {@link Repository} item as a {@link Map}.
* Get a {@link (Repository:interface) | Repository} item as a {@link MapConstructor}.
*

@@ -216,6 +275,9 @@ * @remarks

* ```
*
* @public
* @decorator `@bind`
*/
getMap(key?: string): Map<string, any>;
/**
* Set a {@link Repository} value
* Set a {@link (Repository:interface) | Repository} value
*

@@ -226,2 +288,5 @@ * @example

* ```
*
* @public
* @decorator `@bind`
*/

@@ -239,6 +304,12 @@ set(key: string | number, value: any): this;

* ```
*
* @param key - The key of the item to transform
* @param fn - The function to transform the item with
*
* @public
* @decorator `@bind`
*/
transform(key: string | number, mutationFn: (value?: any) => any): any;
/**
* Mutate a {@link Repository} item
* Mutate a {@link (Repository:interface) | Repository} item
*

@@ -249,6 +320,12 @@ * @example

* ```
*
* @param key - The key of the item to mutate
* @param mutationFn - The mutation function to run on the item
*
* @public
* @decorator `@bind`
*/
mutate(key: string | number, mutationFn: (value?: any) => any): this;
/**
* Merge a supplied value with an existing {@link Repository} value
* Merge a supplied value with an existing {@link (Repository:interface) | Repository} value
*

@@ -259,2 +336,8 @@ * @example

* ```
*
* @param key - The key of the item to merge
* @param value - The value to merge with the existing value
*
* @public
* @decorator `@bind`
*/

@@ -270,2 +353,5 @@ merge(key: string | number, value: any): this;

* ```
*
* @public
* @decorator `@bind`
*/

@@ -283,2 +369,5 @@ has(key: string | number | number): boolean;

* ```
*
* @public
* @decorator `@bind`
*/

@@ -294,2 +383,5 @@ remove(key: string | number): this;

* ```
*
* @public
* @decorator `@bind`
*/

@@ -305,2 +397,8 @@ is(key: string | number, value: any): boolean;

* ```
*
* @param key - The key to check
* @returns True if the key's value is true
*
* @public
* @decorator `@bind`
*/

@@ -316,2 +414,8 @@ isTrue(key: string | number): boolean;

* ```
*
* @param key - The key to check
* @returns True if the key's value is false
*
* @public
* @decorator `@bind`
*/

@@ -327,2 +431,8 @@ isFalse(key: string | number): boolean;

* ```
*
* @param key - The key to check
* @returns True if the key is likely an object.
*
* @public
* @decorator `@bind`
*/

@@ -338,2 +448,8 @@ isIndexed(key?: string | number): boolean;

* ```
*
* @param key - The key to check
* @returns True if the value is an array
*
* @public
* @decorator `@bind`
*/

@@ -349,2 +465,8 @@ isArray(key: string | number): boolean;

* ```
*
* @param key - The key to check
* @returns True if object is not an array
*
* @public
* @decorator `@bind`
*/

@@ -360,6 +482,12 @@ isNotArray(key: string | number): boolean;

* ```
*
* @param key - The key to check
* @returns True if object is a string
*
* @public
* @decorator `@bind`
*/
isString(key: string | number): boolean;
/**
* Return true if object is a string.
* Return true if object is not a string.
*

@@ -371,2 +499,8 @@ * @example

* ```
*
* @param key - The key to check
* @returns True if object is not a string
*
* @public
* @decorator `@bind`
*/

@@ -382,2 +516,8 @@ isNotString(key: string | number): boolean;

* ```
*
* @param key - The key to check
* @returns True if object is a number
*
* @public
* @decorator `@bind`
*/

@@ -393,2 +533,8 @@ isNumber(key: string | number): boolean;

* ```
*
* @param key - The key to check
* @returns True if object is not a number
*
* @public
* @decorator `@bind`
*/

@@ -404,2 +550,5 @@ isNotNumber(key: string | number): boolean;

* ```
*
* @param key - The key to check
* @returns True if object is null
*/

@@ -415,2 +564,8 @@ isNull(key: string | number): boolean;

* ```
*
* @param key - The key to check
* @returns True if object is not null
*
* @public
* @decorator `@bind`
*/

@@ -422,10 +577,17 @@ isNotNull(key: string | number): boolean;

* @example
* True if container has a 'my-key' entry with a definite value.
*
* ```js
* container.isDefined('my-key')
* // True if container has a 'my-key' entry with a definite value.
* ```
*
* @param key - The key to check.
* @returns True if the key is defined.
*
* @public
* @decorator `@bind`
*/
isDefined(key: string | number): boolean;
/**
* Return true if object is defined.
* Return true if object is not defined.
*

@@ -437,2 +599,8 @@ * @example

* ```
*
* @param key - The key to check.
* @returns True if the key is not defined.
*
* @public
* @decorator `@bind`
*/

@@ -447,3 +615,9 @@ isUndefined(key: string | number): boolean;

* // True if object associated with 'my-key' is a fn.
* ````
* ```
*
* @param key - The key to check.
* @returns True if object is a function.
*
* @public
* @decorator `@bind`
*/

@@ -450,0 +624,0 @@ isFunction(key: string | number): boolean;

export { Container } from './Container';
export { Repository } from './Repository';
export type { Repository } from './Repository';
//# sourceMappingURL=index.d.ts.map
/**
* Indexed container value store.
*
* @public
*/

@@ -7,3 +9,13 @@ interface Repository {

}
/**
* Repository namespace
*
* @public
*/
declare namespace Repository {
/**
* Repository key
*
* @public
*/
type Key<I> = (string | number) & keyof I;

@@ -10,0 +22,0 @@ }

/**
* `@roots/container` is a utility to make working with collections of data simple and chainable.
* The {@link @roots/container# | @roots/container} package provides
* a simple chainable interface for working with collections of data
*
* @packageDocumentation
* @packageDocumentation @betaDocumentation
*/
import { Container, Repository } from './Container';
export { Container, Repository };
export { Container } from './Container';
export type { Repository } from './Container/Repository';
//# sourceMappingURL=index.d.ts.map

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

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