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
922
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.2.0 to 4.3.0

1375

lib/cjs/Container/index.js

@@ -1,6 +0,6 @@

'use strict'
Object.defineProperty(exports, '__esModule', {value: true})
exports.Container = void 0
const tslib_1 = require('tslib')
const lodash_1 = tslib_1.__importDefault(require('lodash'))
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Container = void 0;
const tslib_1 = require("tslib");
const lodash_1 = tslib_1.__importDefault(require("lodash"));
/**

@@ -10,777 +10,598 @@ * @roots/container

class Container {
/**
* Class constructor
*/
constructor(repository) {
this.setStore(
repository !== null && repository !== void 0
? repository
: {},
)
}
/**
* ## container.all
*
* Does the same thing as container.all
*
* ### Usage
*
* ```js
* container.all()
* ```
*/
all() {
return this.repository
}
/**
* ## container.setStore
*
* Replace the store with an all new set of values
*
* ### Usage
*
* ```js
* container.setStore({
* new: ['store', 'contents'],
* })
* ```
*/
setStore(repository) {
this.repository = repository
return this
}
/**
* ## container.mergeStore
*
* Merge values onto the container store.
*
* ### Usage
*
* ```js
* container.mergeStore({test: 'foo'})
* ```
*/
mergeStore(values) {
this.setStore(
Object.assign(Object.assign({}, this.all()), values),
)
return this
}
/**
* ## container.transformStore
*
* Retrieve the container store, running it through the supplied fn.
*
* Returns the transformed value.
*
* ### Usage
*
* ```js
* container.transform(store=> modifiedStore)
* ```
*/
transformStore(transformFn) {
return transformFn(this.all())
}
/**
* ## container.mutateStore
*
* Mutate the container store.
*
* ### Usage
*
* ```js
* container.mutate('key', currentValue => modifiedValue)
* ```
*/
mutateStore(mutationFn) {
const transform = this.transformStore(mutationFn)
this.setStore(transform)
return this
}
/**
* ## container.mutateStore
*
* Mutate the container store.
*
* ### Usage
*
* ```js
* container.mutateStoreEntries((key, value) => value + 1)
* ```
*/
mutateStoreEntries(mutateFn) {
this.fromEntries(
this.getEntries().map(([key, value]) => [
key,
mutateFn(key, value),
]),
)
return this
}
/**
* ## container.get
*
* Get a value from the container.
*
* If no key is passed the container store will be returned.
*
* ### Usage
*
* ```js
* container.get('container.container-item')
* ```
*
* ```js
* container.get(['container', 'container-item'])
* ```
*/
get(key) {
return lodash_1.default.get(this.repository, key)
}
/**
* ## container.getEntries
*
* Get container value as [K, V] tuples.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getEntries()
* ```
*
* ```js
* container.getEntries('key')
* ```
*/
getEntries(key) {
let data = []
if (!key) {
this.all() &&
Object.entries(this.all()).map(entry => data.push(entry))
} else {
this.has(key) &&
this.isIndexed(key) &&
Object.entries(this.get(key)).map(entry =>
data.push(entry),
)
/**
* Class constructor
*/
constructor(repository) {
this.setStore(repository !== null && repository !== void 0 ? repository : {});
}
return data
}
/**
* ## container.fromEntries
*
* Set container value from [K, V] tuples.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getEntries()
* ```
*
* ```js
* container.getEntries('key')
* ```
*/
fromEntries(entries) {
this.mergeStore(Object.fromEntries(entries))
return this
}
/**
* ## container.withEntries
*
* Use each value as parameters in a supplied callback
*
* ### Usage
*
* ```js
* container.withEntries('key', (key, value) => doSomething)
* ```
*/
each(key, callFn) {
this.getEntries(key).forEach(([key, value]) => [
key,
callFn(key, value),
])
return this
}
/**
* ## container.every
*
* Use each value as parameters in a supplied callback
*
* ### Usage
*
* ```js
* container.withEntries('key', (key, value) => doSomething)
* ```
*/
every(fn) {
this.getEntries().forEach(([key, value]) => {
fn(key, value)
})
return this
}
/**
* Find
*/
find(...searchItem) {
return lodash_1.default.findKey(
this.repository,
...searchItem,
)
}
/**
* Find in container item
*/
findIn(key, ...searchItem) {
const parseInner = v =>
(!lodash_1.default.isArray(v)
? Object.entries(v)
: v
).reduce(
(a, [k, v]) =>
Object.assign(Object.assign({}, a), {[k]: v}),
{},
)
return lodash_1.default.findKey(
parseInner(this.get(key)),
...searchItem,
)
}
/**
* ## container.mutateEntries
*
* Mutate each value via a supplied mutagen.
*
* ### Usage
*
* ```js
* container.mutateEntries('key', (key, value) => value + 1)
* ```
*/
mutateEntries(key, mutateFn) {
this.fromEntries(
this.getEntries(key).map(([key, value]) => [
key,
mutateFn(key, value),
]),
)
return this
}
/**
* ## container.getValues
*
* Get an item value.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getValues('container.container-item')
* ```
*
* ```js
* container.getValues()
* // => returns values from entire store
* ```
*/
getValues(key) {
return Object.values(key ? this.get(key) : this.all())
}
/**
* ## container.getKeys
*
* Get an item's keys.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getKeys('item')
* // => returns keys of container.repository[item]
* ```
*
* ```js
* container.getKeys()
* // => returns keys of container.repository
* ```
*/
getKeys(key) {
return Object.keys(key ? this.get(key) : this.all())
}
/**
* ## container.getMap
*
* Get an item as a Map datatype.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getMap('item')
* ```
*
* ```js
* container.getMap()
* ```
*/
getMap(key) {
const reducer = [
(map, [key, value]) => {
map.set(key, value)
return map
},
new Map(),
]
return this.getEntries(
key !== null && key !== void 0 ? key : null,
).reduce(...reducer)
}
/**
* ## container.set
*
* Set a value on a container item.
*
* ### Usage
*
* ```js
* container.set('key', value)
* ```
*/
set(key, value) {
lodash_1.default.set(this.repository, key, value)
return this
}
/**
* ## container.push
*
* Push an item or entry onto the container
*
* ```js
* container.unique('containerKey') // unique values of containerKey
* ```
*
* ```js
* container.unique() // unique values of container
* ```
*/
push(value, key) {
if (key) {
this.mutate(key, k => k.push(value))
return this
/**
* ## container.all
*
* Does the same thing as container.all
*
* ### Usage
*
* ```js
* container.all()
* ```
*/
all() {
return this.repository;
}
if (!lodash_1.default.isArray(this.all())) {
throw new Error(
'Type mismatch: Attempted to push onto object container as if it were an array.',
)
/**
* ## container.setStore
*
* Replace the store with an all new set of values
*
* ### Usage
*
* ```js
* container.setStore({
* new: ['store', 'contents'],
* })
* ```
*/
setStore(repository) {
this.repository = repository;
return this;
}
this.setStore(this.all().push(value))
return this
}
/**
* ## container.transform
*
* Retrieve a container item, running it through the supplied fn.
*
* Returns the transformed value.
*
* ### Usage
*
* ```js
* container.transform('key', currentValue => modifiedValue)
* ```
*/
transform(key, mutationFn) {
return mutationFn(this.get(key))
}
/**
* ## container.mutate
*
* Mutate a container item.
*
* ### Usage
*
* ```js
* container.mutate('key', currentValue => modifiedValue)
* ```
*/
mutate(key, mutationFn) {
this.set(key, this.transform(key, mutationFn))
return this
}
/**
* ## container.merge
*
* Merge a container item.
*
* If no key is supplied the value will be merged onto the store itself.
*
* ```js
* container.merge('key', {merge: values})
* ```
*/
merge(key, value) {
this.set(key, lodash_1.default.merge(this.get(key), value))
return this
}
/**
* ## container.has
*
* Return a boolean indicating if a given key exists.
*
* ### Usage
*
* ```js
* container.has('my-key')
* // true if container.repository['my-key'] exists
* ```
*/
has(key) {
return lodash_1.default.has(this.repository, key)
? true
: false
}
/**
* ## container.delete
*
* Delete an entry from the repository
*
* ### Usage
*
* ```js
* container.remove('my-key')
* // Remove container.repository['my-key']
* ```
*/
remove(key) {
delete this.repository[key]
return this
}
/**
* ## container.is
*
* Return a boolean indicating if the given key matches the given value.
*
* ### Usage
*
* ```js
* container.is('my-key', {whatever: 'value'})
* // True if container.repository['my-key'] === {whatever: 'value'}
* ```
*/
is(key, value) {
return this.get(key) === value
}
/**
* ## container.isTrue
*
* Return a boolean indicating if the given key's value is true
*
* ### Usage
*
* ```js
* container.isTrue('my-key')
* // True if container.repository['my-key'] === true
* ```
*/
isTrue(key) {
return this.is(key, true || 'true')
}
/**
* ## container.enabled
*
* Same as container.isTrue.
*
* Return a boolean indicating if the given key's value is true
*
* ### Usage
*
* ```js
* container.isTrue('my-key')
* // True if container.repository['my-key'] === true
* ```
*/
enabled(key) {
return this.is(key, true || 'true')
}
/**
* ## container.isFalse
*
* Return a boolean indicating if the given key's value is false
*
* ### Usage
*
* ```js
* container.isFalse('my-key')
* // True if container.repository['my-key'] === false
* ```
*/
isFalse(key) {
return this.is(key, false || 'false')
}
/**
* ## container.disabled
*
* Same as container.isFalse
*
* Return a boolean indicating if the given key's value is `false`
*
* ### Usage
*
* ```js
* container.isFalse('my-key')
* // True if container.repository['my-key'] === false
* ```
*/
disabled(key) {
return this.isFalse(key || 'false')
}
/**
* ## container.enable
*
* Set the value of the given key to `true`.
*
* ### Usage
*
* ```js
* container.enable('my-key')
* // => container.repository['my-key'] === false
* ```
*/
enable(key) {
this.set(key, true)
}
/**
* ## container.disable
*
* Set the value of the given key to `false`.
*
* ### Usage
*
* ```js
* container.disable('my-key')
* // => container.repository['my-key'] === false
* ```
*/
disable(key) {
this.set(key, false)
}
/**
* ## container.isIndexed
*
* Return true if object is likely a vanilla object with
* string keys.
*
* ### Usage
*
* ```js
* container.isIndexed('my-key')
* // True if container.repository['my-key'] appears to be an object.
* ```
*/
isIndexed(key) {
const value = key ? this.get(key) : this.all()
return (
this.has(key) &&
lodash_1.default.isObject(value) &&
!lodash_1.default.isArrayLikeObject(value)
)
}
/**
* ## container.isArray
*
* Return true if object is an array.
*
* ### Usage
*
* ```js
* container.isArray('my-key')
* // True if container.repository['my-key'] is an array
* ```
*/
isArray(key) {
return (
this.has(key) && lodash_1.default.isArray(this.get(key))
)
}
/**
* ## container.isNotArray
*
* Return true if object is not an array.
*
* ### Usage
*
* ```js
* container.isNotArray('my-key')
* // True if container.repository['my-key'] is not an array
* ```
*/
isNotArray(key) {
return (
this.has(key) && !lodash_1.default.isArray(this.get(key))
)
}
/**
* ## container.isString
*
* Return true if object is a string.
*
* ### Usage
*
* ```js
* container.isString('my-key')
* // True if container.repository['my-key'] is a string
* ```
*/
isString(key) {
return (
this.has(key) && lodash_1.default.isString(this.get(key))
)
}
/**
* ## container.isNotString
*
* Return true if object is a string.
*
* ### Usage
*
* ```js
* container.isString('my-key')
* // True if container.repository['my-key'] is not a string
* ```
*/
isNotString(key) {
return (
this.has(key) && !lodash_1.default.isString(this.get(key))
)
}
/**
* ## container.isNumber
*
* Return true if object is a number.
*
* ### Usage
*
* ```js
* container.isNumber('my-key')
* // True if container.repository['my-key'] is a number
* ```
*/
isNumber(key) {
return (
this.has(key) && lodash_1.default.isNumber(this.get(key))
)
}
/**
* ## container.isNotNumber
*
* Return true if object is not a number.
*
* ### Usage
*
* ```js
* container.isNumber('my-key')
* // True if container.repository['my-key'] is not a number
* ```
*/
isNotNumber(key) {
return (
this.has(key) && !lodash_1.default.isNumber(this.get(key))
)
}
/**
* ## container.isNull
*
* Return true if object is null.
*
* ### Usage
*
* ```js
* container.isNull('my-key')
* // True if container.repository['my-key'] is null
* ```
*/
isNull(key) {
return (
this.has(key) && lodash_1.default.isNull(this.get(key))
)
}
/**
* ## container.isNotNull
*
* Return true if object is not null.
*
* ### Usage
*
* ```js
* container.isNotNull('my-key')
* // True if container.repository['my-key'] is not null
* ```
*/
isNotNull(key) {
return (
this.has(key) && !lodash_1.default.isNull(this.get(key))
)
}
/**
* ## container.isDefined
*
* Return true if object is defined.
*
* ### Usage
*
* ```js
* container.isDefined('my-key')
* // True if container has a 'my-key' entry with a definite value.
* ```
*/
isDefined(key) {
return (
this.has(key) &&
!lodash_1.default.isUndefined(this.get(key))
)
}
/**
* ## container.isUndefined
*
* Return true if object is defined.
*
* ### Usage
*
* ```js
* container.isDefined('my-key')
* // True if container has a 'my-key' entry with a definite value.
* ```
*/
isUndefined(key) {
return (
!this.has(key) ||
lodash_1.default.isUndefined(this.get(key))
)
}
/**
* ## container.isFunction
*
* Return true if object is a function
*
* ### Usage
*
* ```js
* container.isFunction('my-key')
* // True if object associated with 'my-key' is a fn.
* ````
*/
isFunction(key) {
return lodash_1.default.isFunction(this.get(key))
}
/**
* ## container.mergeStore
*
* Merge values onto the container store.
*
* ### Usage
*
* ```js
* container.mergeStore({test: 'foo'})
* ```
*/
mergeStore(values) {
this.setStore(Object.assign(Object.assign({}, this.all()), values));
return this;
}
/**
* ## container.transformStore
*
* Retrieve the container store, running it through the supplied fn.
*
* Returns the transformed value.
*
* ### Usage
*
* ```js
* container.transform(store=> modifiedStore)
* ```
*/
transformStore(transformFn) {
return transformFn(this.all());
}
/**
* ## container.mutateStore
*
* Mutate the container store.
*
* ### Usage
*
* ```js
* container.mutate('key', currentValue => modifiedValue)
* ```
*/
mutateStore(mutationFn) {
const transform = this.transformStore(mutationFn);
this.setStore(transform);
return this;
}
/**
* ## container.get
*
* Get a value from the container.
*
* If no key is passed the container store will be returned.
*
* ### Usage
*
* ```js
* container.get('container.container-item')
* ```
*
* ```js
* container.get(['container', 'container-item'])
* ```
*/
get(key) {
return lodash_1.default.get(this.repository, key);
}
/**
* ## container.getEntries
*
* Get container value as [K, V] tuples.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getEntries()
* ```
*
* ```js
* container.getEntries('key')
* ```
*/
getEntries(key) {
let data = [];
if (!key) {
this.all() &&
Object.entries(this.all()).map(entry => data.push(entry));
}
else {
this.has(key) &&
this.isIndexed(key) &&
Object.entries(this.get(key)).map(entry => data.push(entry));
}
return data;
}
/**
* ## container.fromEntries
*
* Set container value from [K, V] tuples.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getEntries()
* ```
*
* ```js
* container.getEntries('key')
* ```
*/
fromEntries(entries) {
this.mergeStore(Object.fromEntries(entries));
return this;
}
/**
* ## container.withEntries
*
* Use each value as parameters in a supplied callback
*
* ### Usage
*
* ```js
* container.withEntries('key', (key, value) => doSomething)
* ```
*/
each(key, callFn) {
this.getEntries(key).forEach(([key, value]) => [
key,
callFn(key, value),
]);
return this;
}
/**
* ## container.every
*
* Use each value as parameters in a supplied callback
*
* ### Usage
*
* ```js
* container.withEntries('key', (key, value) => doSomething)
* ```
*/
every(fn) {
this.getEntries().forEach(([key, value]) => {
fn(key, value);
});
return this;
}
/**
* Find
*/
findKey(...searchItem) {
return lodash_1.default.findKey(this.repository, ...searchItem);
}
/**
* Find in container item
*/
findKeyIn(key, ...searchItem) {
const parseInner = v => (!lodash_1.default.isArray(v) ? Object.entries(v) : v).reduce((a, [k, v]) => (Object.assign(Object.assign({}, a), { [k]: v })), {});
return lodash_1.default.findKey(parseInner(this.get(key)), ...searchItem);
}
/**
* ## container.getValues
*
* Get an item value.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getValues('container.container-item')
* ```
*
* ```js
* container.getValues()
* // => returns values from entire store
* ```
*/
getValues(key) {
return Object.values(key ? this.get(key) : this.all());
}
/**
* ## container.getKeys
*
* Get an item's keys.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getKeys('item')
* // => returns keys of container.repository[item]
* ```
*
* ```js
* container.getKeys()
* // => returns keys of container.repository
* ```
*/
getKeys(key) {
return Object.keys(key ? this.get(key) : this.all());
}
/**
* ## container.getMap
*
* Get an item as a Map datatype.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getMap('item')
* ```
*
* ```js
* container.getMap()
* ```
*/
getMap(key) {
const reducer = [
(map, [key, value]) => {
map.set(key, value);
return map;
},
new Map(),
];
return this.getEntries(key !== null && key !== void 0 ? key : null).reduce(...reducer);
}
/**
* ## container.set
*
* Set a value on a container item.
*
* ### Usage
*
* ```js
* container.set('key', value)
* ```
*/
set(key, value) {
lodash_1.default.set(this.repository, key, value);
return this;
}
/**
* ## container.transform
*
* Retrieve a container item, running it through the supplied fn.
*
* Returns the transformed value.
*
* ### Usage
*
* ```js
* container.transform('key', currentValue => modifiedValue)
* ```
*/
transform(key, mutationFn) {
return mutationFn(this.get(key));
}
/**
* ## container.mutate
*
* Mutate a container item.
*
* ### Usage
*
* ```js
* container.mutate('key', currentValue => modifiedValue)
* ```
*/
mutate(key, mutationFn) {
this.set(key, this.transform(key, mutationFn));
return this;
}
/**
* ## container.merge
*
* Merge a container item.
*
* If no key is supplied the value will be merged onto the store itself.
*
* ```js
* container.merge('key', {merge: values})
* ```
*/
merge(key, value) {
this.set(key, lodash_1.default.merge(this.get(key), value));
return this;
}
/**
* ## container.has
*
* Return a boolean indicating if a given key exists.
*
* ### Usage
*
* ```js
* container.has('my-key')
* // true if container.repository['my-key'] exists
* ```
*/
has(key) {
return lodash_1.default.has(this.repository, key);
}
/**
* ## container.delete
*
* Delete an entry from the repository
*
* ### Usage
*
* ```js
* container.remove('my-key')
* // Remove container.repository['my-key']
* ```
*/
remove(key) {
delete this.repository[key];
return this;
}
/**
* ## container.is
*
* Return a boolean indicating if the given key matches the given value.
*
* ### Usage
*
* ```js
* container.is('my-key', {whatever: 'value'})
* // True if container.repository['my-key'] === {whatever: 'value'}
* ```
*/
is(key, value) {
return lodash_1.default.isEqual(this.get(key), value);
}
/**
* ## container.isTrue
*
* Return a boolean indicating if the given key's value is true
*
* ### Usage
*
* ```js
* container.isTrue('my-key')
* // True if container.repository['my-key'] === true
* ```
*/
isTrue(key) {
return this.is(key, true);
}
/**
* ## container.isFalse
*
* Return a boolean indicating if the given key's value is false
*
* ### Usage
*
* ```js
* container.isFalse('my-key')
* // True if container.repository['my-key'] === false
* ```
*/
isFalse(key) {
return this.is(key, false);
}
/**
* ## container.isIndexed
*
* Return true if object is likely a vanilla object with
* string keys.
*
* ### Usage
*
* ```js
* container.isIndexed('my-key')
* // True if container.repository['my-key'] appears to be an object.
* ```
*/
isIndexed(key) {
const value = key ? this.get(key) : this.all();
return (this.has(key) &&
lodash_1.default.isObject(value) &&
!lodash_1.default.isArrayLikeObject(value));
}
/**
* ## container.isArray
*
* Return true if object is an array.
*
* ### Usage
*
* ```js
* container.isArray('my-key')
* // True if container.repository['my-key'] is an array
* ```
*/
isArray(key) {
return this.has(key) && lodash_1.default.isArray(this.get(key));
}
/**
* ## container.isNotArray
*
* Return true if object is not an array.
*
* ### Usage
*
* ```js
* container.isNotArray('my-key')
* // True if container.repository['my-key'] is not an array
* ```
*/
isNotArray(key) {
return this.has(key) && !lodash_1.default.isArray(this.get(key));
}
/**
* ## container.isString
*
* Return true if object is a string.
*
* ### Usage
*
* ```js
* container.isString('my-key')
* // True if container.repository['my-key'] is a string
* ```
*/
isString(key) {
return this.has(key) && lodash_1.default.isString(this.get(key));
}
/**
* ## container.isNotString
*
* Return true if object is a string.
*
* ### Usage
*
* ```js
* container.isString('my-key')
* // True if container.repository['my-key'] is not a string
* ```
*/
isNotString(key) {
return this.has(key) && !lodash_1.default.isString(this.get(key));
}
/**
* ## container.isNumber
*
* Return true if object is a number.
*
* ### Usage
*
* ```js
* container.isNumber('my-key')
* // True if container.repository['my-key'] is a number
* ```
*/
isNumber(key) {
return this.has(key) && lodash_1.default.isNumber(this.get(key));
}
/**
* ## container.isNotNumber
*
* Return true if object is not a number.
*
* ### Usage
*
* ```js
* container.isNumber('my-key')
* // True if container.repository['my-key'] is not a number
* ```
*/
isNotNumber(key) {
return this.has(key) && !lodash_1.default.isNumber(this.get(key));
}
/**
* ## container.isNull
*
* Return true if object is null.
*
* ### Usage
*
* ```js
* container.isNull('my-key')
* // True if container.repository['my-key'] is null
* ```
*/
isNull(key) {
return this.has(key) && lodash_1.default.isNull(this.get(key));
}
/**
* ## container.isNotNull
*
* Return true if object is not null.
*
* ### Usage
*
* ```js
* container.isNotNull('my-key')
* // True if container.repository['my-key'] is not null
* ```
*/
isNotNull(key) {
return this.has(key) && !lodash_1.default.isNull(this.get(key));
}
/**
* ## container.isDefined
*
* Return true if object is defined.
*
* ### Usage
*
* ```js
* container.isDefined('my-key')
* // True if container has a 'my-key' entry with a definite value.
* ```
*/
isDefined(key) {
return this.has(key) && !lodash_1.default.isUndefined(this.get(key));
}
/**
* ## container.isUndefined
*
* Return true if object is defined.
*
* ### Usage
*
* ```js
* container.isDefined('my-key')
* // True if container has a 'my-key' entry with a definite value.
* ```
*/
isUndefined(key) {
return !this.has(key) || lodash_1.default.isUndefined(this.get(key));
}
/**
* ## container.isFunction
*
* Return true if object is a function
*
* ### Usage
*
* ```js
* container.isFunction('my-key')
* // True if object associated with 'my-key' is a fn.
* ````
*/
isFunction(key) {
return this.has(key) && lodash_1.default.isFunction(this.get(key));
}
}
exports.Container = Container
//# sourceMappingURL=index.js.map
exports.Container = Container;
//# sourceMappingURL=index.js.map

@@ -1,11 +0,6 @@

'use strict'
Object.defineProperty(exports, '__esModule', {value: true})
exports.Container = void 0
var index_1 = require('./Container/index')
Object.defineProperty(exports, 'Container', {
enumerable: true,
get: function () {
return index_1.Container
},
})
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Container = void 0;
var index_1 = require("./Container/index");
Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return index_1.Container; } });
//# sourceMappingURL=index.js.map

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

import _ from 'lodash'
import _ from 'lodash';
/**

@@ -6,743 +6,597 @@ * @roots/container

export class Container {
/**
* Class constructor
*/
constructor(repository) {
this.setStore(
repository !== null && repository !== void 0
? repository
: {},
)
}
/**
* ## container.all
*
* Does the same thing as container.all
*
* ### Usage
*
* ```js
* container.all()
* ```
*/
all() {
return this.repository
}
/**
* ## container.setStore
*
* Replace the store with an all new set of values
*
* ### Usage
*
* ```js
* container.setStore({
* new: ['store', 'contents'],
* })
* ```
*/
setStore(repository) {
this.repository = repository
return this
}
/**
* ## container.mergeStore
*
* Merge values onto the container store.
*
* ### Usage
*
* ```js
* container.mergeStore({test: 'foo'})
* ```
*/
mergeStore(values) {
this.setStore(
Object.assign(Object.assign({}, this.all()), values),
)
return this
}
/**
* ## container.transformStore
*
* Retrieve the container store, running it through the supplied fn.
*
* Returns the transformed value.
*
* ### Usage
*
* ```js
* container.transform(store=> modifiedStore)
* ```
*/
transformStore(transformFn) {
return transformFn(this.all())
}
/**
* ## container.mutateStore
*
* Mutate the container store.
*
* ### Usage
*
* ```js
* container.mutate('key', currentValue => modifiedValue)
* ```
*/
mutateStore(mutationFn) {
const transform = this.transformStore(mutationFn)
this.setStore(transform)
return this
}
/**
* ## container.mutateStore
*
* Mutate the container store.
*
* ### Usage
*
* ```js
* container.mutateStoreEntries((key, value) => value + 1)
* ```
*/
mutateStoreEntries(mutateFn) {
this.fromEntries(
this.getEntries().map(([key, value]) => [
key,
mutateFn(key, value),
]),
)
return this
}
/**
* ## container.get
*
* Get a value from the container.
*
* If no key is passed the container store will be returned.
*
* ### Usage
*
* ```js
* container.get('container.container-item')
* ```
*
* ```js
* container.get(['container', 'container-item'])
* ```
*/
get(key) {
return _.get(this.repository, key)
}
/**
* ## container.getEntries
*
* Get container value as [K, V] tuples.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getEntries()
* ```
*
* ```js
* container.getEntries('key')
* ```
*/
getEntries(key) {
let data = []
if (!key) {
this.all() &&
Object.entries(this.all()).map(entry => data.push(entry))
} else {
this.has(key) &&
this.isIndexed(key) &&
Object.entries(this.get(key)).map(entry =>
data.push(entry),
)
/**
* Class constructor
*/
constructor(repository) {
this.setStore(repository !== null && repository !== void 0 ? repository : {});
}
return data
}
/**
* ## container.fromEntries
*
* Set container value from [K, V] tuples.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getEntries()
* ```
*
* ```js
* container.getEntries('key')
* ```
*/
fromEntries(entries) {
this.mergeStore(Object.fromEntries(entries))
return this
}
/**
* ## container.withEntries
*
* Use each value as parameters in a supplied callback
*
* ### Usage
*
* ```js
* container.withEntries('key', (key, value) => doSomething)
* ```
*/
each(key, callFn) {
this.getEntries(key).forEach(([key, value]) => [
key,
callFn(key, value),
])
return this
}
/**
* ## container.every
*
* Use each value as parameters in a supplied callback
*
* ### Usage
*
* ```js
* container.withEntries('key', (key, value) => doSomething)
* ```
*/
every(fn) {
this.getEntries().forEach(([key, value]) => {
fn(key, value)
})
return this
}
/**
* Find
*/
find(...searchItem) {
return _.findKey(this.repository, ...searchItem)
}
/**
* Find in container item
*/
findIn(key, ...searchItem) {
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)
}
/**
* ## container.mutateEntries
*
* Mutate each value via a supplied mutagen.
*
* ### Usage
*
* ```js
* container.mutateEntries('key', (key, value) => value + 1)
* ```
*/
mutateEntries(key, mutateFn) {
this.fromEntries(
this.getEntries(key).map(([key, value]) => [
key,
mutateFn(key, value),
]),
)
return this
}
/**
* ## container.getValues
*
* Get an item value.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getValues('container.container-item')
* ```
*
* ```js
* container.getValues()
* // => returns values from entire store
* ```
*/
getValues(key) {
return Object.values(key ? this.get(key) : this.all())
}
/**
* ## container.getKeys
*
* Get an item's keys.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getKeys('item')
* // => returns keys of container.repository[item]
* ```
*
* ```js
* container.getKeys()
* // => returns keys of container.repository
* ```
*/
getKeys(key) {
return Object.keys(key ? this.get(key) : this.all())
}
/**
* ## container.getMap
*
* Get an item as a Map datatype.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getMap('item')
* ```
*
* ```js
* container.getMap()
* ```
*/
getMap(key) {
const reducer = [
(map, [key, value]) => {
map.set(key, value)
return map
},
new Map(),
]
return this.getEntries(
key !== null && key !== void 0 ? key : null,
).reduce(...reducer)
}
/**
* ## container.set
*
* Set a value on a container item.
*
* ### Usage
*
* ```js
* container.set('key', value)
* ```
*/
set(key, value) {
_.set(this.repository, key, value)
return this
}
/**
* ## container.push
*
* Push an item or entry onto the container
*
* ```js
* container.unique('containerKey') // unique values of containerKey
* ```
*
* ```js
* container.unique() // unique values of container
* ```
*/
push(value, key) {
if (key) {
this.mutate(key, k => k.push(value))
return this
/**
* ## container.all
*
* Does the same thing as container.all
*
* ### Usage
*
* ```js
* container.all()
* ```
*/
all() {
return this.repository;
}
if (!_.isArray(this.all())) {
throw new Error(
'Type mismatch: Attempted to push onto object container as if it were an array.',
)
/**
* ## container.setStore
*
* Replace the store with an all new set of values
*
* ### Usage
*
* ```js
* container.setStore({
* new: ['store', 'contents'],
* })
* ```
*/
setStore(repository) {
this.repository = repository;
return this;
}
this.setStore(this.all().push(value))
return this
}
/**
* ## container.transform
*
* Retrieve a container item, running it through the supplied fn.
*
* Returns the transformed value.
*
* ### Usage
*
* ```js
* container.transform('key', currentValue => modifiedValue)
* ```
*/
transform(key, mutationFn) {
return mutationFn(this.get(key))
}
/**
* ## container.mutate
*
* Mutate a container item.
*
* ### Usage
*
* ```js
* container.mutate('key', currentValue => modifiedValue)
* ```
*/
mutate(key, mutationFn) {
this.set(key, this.transform(key, mutationFn))
return this
}
/**
* ## container.merge
*
* Merge a container item.
*
* If no key is supplied the value will be merged onto the store itself.
*
* ```js
* container.merge('key', {merge: values})
* ```
*/
merge(key, value) {
this.set(key, _.merge(this.get(key), value))
return this
}
/**
* ## container.has
*
* Return a boolean indicating if a given key exists.
*
* ### Usage
*
* ```js
* container.has('my-key')
* // true if container.repository['my-key'] exists
* ```
*/
has(key) {
return _.has(this.repository, key) ? true : false
}
/**
* ## container.delete
*
* Delete an entry from the repository
*
* ### Usage
*
* ```js
* container.remove('my-key')
* // Remove container.repository['my-key']
* ```
*/
remove(key) {
delete this.repository[key]
return this
}
/**
* ## container.is
*
* Return a boolean indicating if the given key matches the given value.
*
* ### Usage
*
* ```js
* container.is('my-key', {whatever: 'value'})
* // True if container.repository['my-key'] === {whatever: 'value'}
* ```
*/
is(key, value) {
return this.get(key) === value
}
/**
* ## container.isTrue
*
* Return a boolean indicating if the given key's value is true
*
* ### Usage
*
* ```js
* container.isTrue('my-key')
* // True if container.repository['my-key'] === true
* ```
*/
isTrue(key) {
return this.is(key, true || 'true')
}
/**
* ## container.enabled
*
* Same as container.isTrue.
*
* Return a boolean indicating if the given key's value is true
*
* ### Usage
*
* ```js
* container.isTrue('my-key')
* // True if container.repository['my-key'] === true
* ```
*/
enabled(key) {
return this.is(key, true || 'true')
}
/**
* ## container.isFalse
*
* Return a boolean indicating if the given key's value is false
*
* ### Usage
*
* ```js
* container.isFalse('my-key')
* // True if container.repository['my-key'] === false
* ```
*/
isFalse(key) {
return this.is(key, false || 'false')
}
/**
* ## container.disabled
*
* Same as container.isFalse
*
* Return a boolean indicating if the given key's value is `false`
*
* ### Usage
*
* ```js
* container.isFalse('my-key')
* // True if container.repository['my-key'] === false
* ```
*/
disabled(key) {
return this.isFalse(key || 'false')
}
/**
* ## container.enable
*
* Set the value of the given key to `true`.
*
* ### Usage
*
* ```js
* container.enable('my-key')
* // => container.repository['my-key'] === false
* ```
*/
enable(key) {
this.set(key, true)
}
/**
* ## container.disable
*
* Set the value of the given key to `false`.
*
* ### Usage
*
* ```js
* container.disable('my-key')
* // => container.repository['my-key'] === false
* ```
*/
disable(key) {
this.set(key, false)
}
/**
* ## container.isIndexed
*
* Return true if object is likely a vanilla object with
* string keys.
*
* ### Usage
*
* ```js
* container.isIndexed('my-key')
* // True if container.repository['my-key'] appears to be an object.
* ```
*/
isIndexed(key) {
const value = key ? this.get(key) : this.all()
return (
this.has(key) &&
_.isObject(value) &&
!_.isArrayLikeObject(value)
)
}
/**
* ## container.isArray
*
* Return true if object is an array.
*
* ### Usage
*
* ```js
* container.isArray('my-key')
* // True if container.repository['my-key'] is an array
* ```
*/
isArray(key) {
return this.has(key) && _.isArray(this.get(key))
}
/**
* ## container.isNotArray
*
* Return true if object is not an array.
*
* ### Usage
*
* ```js
* container.isNotArray('my-key')
* // True if container.repository['my-key'] is not an array
* ```
*/
isNotArray(key) {
return this.has(key) && !_.isArray(this.get(key))
}
/**
* ## container.isString
*
* Return true if object is a string.
*
* ### Usage
*
* ```js
* container.isString('my-key')
* // True if container.repository['my-key'] is a string
* ```
*/
isString(key) {
return this.has(key) && _.isString(this.get(key))
}
/**
* ## container.isNotString
*
* Return true if object is a string.
*
* ### Usage
*
* ```js
* container.isString('my-key')
* // True if container.repository['my-key'] is not a string
* ```
*/
isNotString(key) {
return this.has(key) && !_.isString(this.get(key))
}
/**
* ## container.isNumber
*
* Return true if object is a number.
*
* ### Usage
*
* ```js
* container.isNumber('my-key')
* // True if container.repository['my-key'] is a number
* ```
*/
isNumber(key) {
return this.has(key) && _.isNumber(this.get(key))
}
/**
* ## container.isNotNumber
*
* Return true if object is not a number.
*
* ### Usage
*
* ```js
* container.isNumber('my-key')
* // True if container.repository['my-key'] is not a number
* ```
*/
isNotNumber(key) {
return this.has(key) && !_.isNumber(this.get(key))
}
/**
* ## container.isNull
*
* Return true if object is null.
*
* ### Usage
*
* ```js
* container.isNull('my-key')
* // True if container.repository['my-key'] is null
* ```
*/
isNull(key) {
return this.has(key) && _.isNull(this.get(key))
}
/**
* ## container.isNotNull
*
* Return true if object is not null.
*
* ### Usage
*
* ```js
* container.isNotNull('my-key')
* // True if container.repository['my-key'] is not null
* ```
*/
isNotNull(key) {
return this.has(key) && !_.isNull(this.get(key))
}
/**
* ## container.isDefined
*
* Return true if object is defined.
*
* ### Usage
*
* ```js
* container.isDefined('my-key')
* // True if container has a 'my-key' entry with a definite value.
* ```
*/
isDefined(key) {
return this.has(key) && !_.isUndefined(this.get(key))
}
/**
* ## container.isUndefined
*
* Return true if object is defined.
*
* ### Usage
*
* ```js
* container.isDefined('my-key')
* // True if container has a 'my-key' entry with a definite value.
* ```
*/
isUndefined(key) {
return !this.has(key) || _.isUndefined(this.get(key))
}
/**
* ## container.isFunction
*
* Return true if object is a function
*
* ### Usage
*
* ```js
* container.isFunction('my-key')
* // True if object associated with 'my-key' is a fn.
* ````
*/
isFunction(key) {
return _.isFunction(this.get(key))
}
/**
* ## container.mergeStore
*
* Merge values onto the container store.
*
* ### Usage
*
* ```js
* container.mergeStore({test: 'foo'})
* ```
*/
mergeStore(values) {
this.setStore(Object.assign(Object.assign({}, this.all()), values));
return this;
}
/**
* ## container.transformStore
*
* Retrieve the container store, running it through the supplied fn.
*
* Returns the transformed value.
*
* ### Usage
*
* ```js
* container.transform(store=> modifiedStore)
* ```
*/
transformStore(transformFn) {
return transformFn(this.all());
}
/**
* ## container.mutateStore
*
* Mutate the container store.
*
* ### Usage
*
* ```js
* container.mutate('key', currentValue => modifiedValue)
* ```
*/
mutateStore(mutationFn) {
const transform = this.transformStore(mutationFn);
this.setStore(transform);
return this;
}
/**
* ## container.get
*
* Get a value from the container.
*
* If no key is passed the container store will be returned.
*
* ### Usage
*
* ```js
* container.get('container.container-item')
* ```
*
* ```js
* container.get(['container', 'container-item'])
* ```
*/
get(key) {
return _.get(this.repository, key);
}
/**
* ## container.getEntries
*
* Get container value as [K, V] tuples.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getEntries()
* ```
*
* ```js
* container.getEntries('key')
* ```
*/
getEntries(key) {
let data = [];
if (!key) {
this.all() &&
Object.entries(this.all()).map(entry => data.push(entry));
}
else {
this.has(key) &&
this.isIndexed(key) &&
Object.entries(this.get(key)).map(entry => data.push(entry));
}
return data;
}
/**
* ## container.fromEntries
*
* Set container value from [K, V] tuples.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getEntries()
* ```
*
* ```js
* container.getEntries('key')
* ```
*/
fromEntries(entries) {
this.mergeStore(Object.fromEntries(entries));
return this;
}
/**
* ## container.withEntries
*
* Use each value as parameters in a supplied callback
*
* ### Usage
*
* ```js
* container.withEntries('key', (key, value) => doSomething)
* ```
*/
each(key, callFn) {
this.getEntries(key).forEach(([key, value]) => [
key,
callFn(key, value),
]);
return this;
}
/**
* ## container.every
*
* Use each value as parameters in a supplied callback
*
* ### Usage
*
* ```js
* container.withEntries('key', (key, value) => doSomething)
* ```
*/
every(fn) {
this.getEntries().forEach(([key, value]) => {
fn(key, value);
});
return this;
}
/**
* Find
*/
findKey(...searchItem) {
return _.findKey(this.repository, ...searchItem);
}
/**
* Find in container item
*/
findKeyIn(key, ...searchItem) {
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);
}
/**
* ## container.getValues
*
* Get an item value.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getValues('container.container-item')
* ```
*
* ```js
* container.getValues()
* // => returns values from entire store
* ```
*/
getValues(key) {
return Object.values(key ? this.get(key) : this.all());
}
/**
* ## container.getKeys
*
* Get an item's keys.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getKeys('item')
* // => returns keys of container.repository[item]
* ```
*
* ```js
* container.getKeys()
* // => returns keys of container.repository
* ```
*/
getKeys(key) {
return Object.keys(key ? this.get(key) : this.all());
}
/**
* ## container.getMap
*
* Get an item as a Map datatype.
*
* If no key is passed the container store will be used.
*
* ### Usage
*
* ```js
* container.getMap('item')
* ```
*
* ```js
* container.getMap()
* ```
*/
getMap(key) {
const reducer = [
(map, [key, value]) => {
map.set(key, value);
return map;
},
new Map(),
];
return this.getEntries(key !== null && key !== void 0 ? key : null).reduce(...reducer);
}
/**
* ## container.set
*
* Set a value on a container item.
*
* ### Usage
*
* ```js
* container.set('key', value)
* ```
*/
set(key, value) {
_.set(this.repository, key, value);
return this;
}
/**
* ## container.transform
*
* Retrieve a container item, running it through the supplied fn.
*
* Returns the transformed value.
*
* ### Usage
*
* ```js
* container.transform('key', currentValue => modifiedValue)
* ```
*/
transform(key, mutationFn) {
return mutationFn(this.get(key));
}
/**
* ## container.mutate
*
* Mutate a container item.
*
* ### Usage
*
* ```js
* container.mutate('key', currentValue => modifiedValue)
* ```
*/
mutate(key, mutationFn) {
this.set(key, this.transform(key, mutationFn));
return this;
}
/**
* ## container.merge
*
* Merge a container item.
*
* If no key is supplied the value will be merged onto the store itself.
*
* ```js
* container.merge('key', {merge: values})
* ```
*/
merge(key, value) {
this.set(key, _.merge(this.get(key), value));
return this;
}
/**
* ## container.has
*
* Return a boolean indicating if a given key exists.
*
* ### Usage
*
* ```js
* container.has('my-key')
* // true if container.repository['my-key'] exists
* ```
*/
has(key) {
return _.has(this.repository, key);
}
/**
* ## container.delete
*
* Delete an entry from the repository
*
* ### Usage
*
* ```js
* container.remove('my-key')
* // Remove container.repository['my-key']
* ```
*/
remove(key) {
delete this.repository[key];
return this;
}
/**
* ## container.is
*
* Return a boolean indicating if the given key matches the given value.
*
* ### Usage
*
* ```js
* container.is('my-key', {whatever: 'value'})
* // True if container.repository['my-key'] === {whatever: 'value'}
* ```
*/
is(key, value) {
return _.isEqual(this.get(key), value);
}
/**
* ## container.isTrue
*
* Return a boolean indicating if the given key's value is true
*
* ### Usage
*
* ```js
* container.isTrue('my-key')
* // True if container.repository['my-key'] === true
* ```
*/
isTrue(key) {
return this.is(key, true);
}
/**
* ## container.isFalse
*
* Return a boolean indicating if the given key's value is false
*
* ### Usage
*
* ```js
* container.isFalse('my-key')
* // True if container.repository['my-key'] === false
* ```
*/
isFalse(key) {
return this.is(key, false);
}
/**
* ## container.isIndexed
*
* Return true if object is likely a vanilla object with
* string keys.
*
* ### Usage
*
* ```js
* container.isIndexed('my-key')
* // True if container.repository['my-key'] appears to be an object.
* ```
*/
isIndexed(key) {
const value = key ? this.get(key) : this.all();
return (this.has(key) &&
_.isObject(value) &&
!_.isArrayLikeObject(value));
}
/**
* ## container.isArray
*
* Return true if object is an array.
*
* ### Usage
*
* ```js
* container.isArray('my-key')
* // True if container.repository['my-key'] is an array
* ```
*/
isArray(key) {
return this.has(key) && _.isArray(this.get(key));
}
/**
* ## container.isNotArray
*
* Return true if object is not an array.
*
* ### Usage
*
* ```js
* container.isNotArray('my-key')
* // True if container.repository['my-key'] is not an array
* ```
*/
isNotArray(key) {
return this.has(key) && !_.isArray(this.get(key));
}
/**
* ## container.isString
*
* Return true if object is a string.
*
* ### Usage
*
* ```js
* container.isString('my-key')
* // True if container.repository['my-key'] is a string
* ```
*/
isString(key) {
return this.has(key) && _.isString(this.get(key));
}
/**
* ## container.isNotString
*
* Return true if object is a string.
*
* ### Usage
*
* ```js
* container.isString('my-key')
* // True if container.repository['my-key'] is not a string
* ```
*/
isNotString(key) {
return this.has(key) && !_.isString(this.get(key));
}
/**
* ## container.isNumber
*
* Return true if object is a number.
*
* ### Usage
*
* ```js
* container.isNumber('my-key')
* // True if container.repository['my-key'] is a number
* ```
*/
isNumber(key) {
return this.has(key) && _.isNumber(this.get(key));
}
/**
* ## container.isNotNumber
*
* Return true if object is not a number.
*
* ### Usage
*
* ```js
* container.isNumber('my-key')
* // True if container.repository['my-key'] is not a number
* ```
*/
isNotNumber(key) {
return this.has(key) && !_.isNumber(this.get(key));
}
/**
* ## container.isNull
*
* Return true if object is null.
*
* ### Usage
*
* ```js
* container.isNull('my-key')
* // True if container.repository['my-key'] is null
* ```
*/
isNull(key) {
return this.has(key) && _.isNull(this.get(key));
}
/**
* ## container.isNotNull
*
* Return true if object is not null.
*
* ### Usage
*
* ```js
* container.isNotNull('my-key')
* // True if container.repository['my-key'] is not null
* ```
*/
isNotNull(key) {
return this.has(key) && !_.isNull(this.get(key));
}
/**
* ## container.isDefined
*
* Return true if object is defined.
*
* ### Usage
*
* ```js
* container.isDefined('my-key')
* // True if container has a 'my-key' entry with a definite value.
* ```
*/
isDefined(key) {
return this.has(key) && !_.isUndefined(this.get(key));
}
/**
* ## container.isUndefined
*
* Return true if object is defined.
*
* ### Usage
*
* ```js
* container.isDefined('my-key')
* // True if container has a 'my-key' entry with a definite value.
* ```
*/
isUndefined(key) {
return !this.has(key) || _.isUndefined(this.get(key));
}
/**
* ## container.isFunction
*
* Return true if object is a function
*
* ### Usage
*
* ```js
* container.isFunction('my-key')
* // True if object associated with 'my-key' is a fn.
* ````
*/
isFunction(key) {
return this.has(key) && _.isFunction(this.get(key));
}
}
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map

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

export {Container} from './Container/index'
//# sourceMappingURL=index.js.map
export { Container } from './Container/index';
//# sourceMappingURL=index.js.map
{
"name": "@roots/container",
"version": "4.2.0",
"version": "4.3.0",
"description": "Collections utility",

@@ -49,2 +49,5 @@ "homepage": "https://roots.io/bud",

"build:esm": "yarn g:build:esm",
"profile": "yarn g:profile",
"profile:cjs": "yarn g:profile:cjs",
"profile:esm": "yarn g:profile:esm",
"lint": "yarn g:lint",

@@ -62,4 +65,4 @@ "lint:eslint": "yarn g:lint:eslint",

"devDependencies": {
"@types/node": "^15.0.0",
"type-fest": "^1.0.2"
"@types/node": "^15.6.1",
"type-fest": "^1.1.3"
},

@@ -66,0 +69,0 @@ "dependencies": {

@@ -89,14 +89,2 @@ import { ValueOf } from 'type-fest';

/**
* ## container.mutateStore
*
* Mutate the container store.
*
* ### Usage
*
* ```js
* container.mutateStoreEntries((key, value) => value + 1)
* ```
*/
mutateStoreEntries(mutateFn: (key: string | number, value: I) => I): this;
/**
* ## container.get

@@ -182,20 +170,8 @@ *

*/
find(...searchItem: any): any;
findKey(...searchItem: any): any;
/**
* Find in container item
*/
findIn(key: string | number, ...searchItem: any[]): any;
findKeyIn(key: string | number, ...searchItem: any[]): any;
/**
* ## container.mutateEntries
*
* Mutate each value via a supplied mutagen.
*
* ### Usage
*
* ```js
* container.mutateEntries('key', (key, value) => value + 1)
* ```
*/
mutateEntries(key: string | number, mutateFn: (key: string | number, value: any) => any): this;
/**
* ## container.getValues

@@ -270,16 +246,2 @@ *

/**
* ## container.push
*
* Push an item or entry onto the container
*
* ```js
* container.unique('containerKey') // unique values of containerKey
* ```
*
* ```js
* container.unique() // unique values of container
* ```
*/
push(value: any, key?: any): this;
/**
* ## container.transform

@@ -375,17 +337,2 @@ *

/**
* ## container.enabled
*
* Same as container.isTrue.
*
* Return a boolean indicating if the given key's value is true
*
* ### Usage
*
* ```js
* container.isTrue('my-key')
* // True if container.repository['my-key'] === true
* ```
*/
enabled(key: string | number): boolean;
/**
* ## container.isFalse

@@ -404,43 +351,2 @@ *

/**
* ## container.disabled
*
* Same as container.isFalse
*
* Return a boolean indicating if the given key's value is `false`
*
* ### Usage
*
* ```js
* container.isFalse('my-key')
* // True if container.repository['my-key'] === false
* ```
*/
disabled(key: string | number): boolean;
/**
* ## container.enable
*
* Set the value of the given key to `true`.
*
* ### Usage
*
* ```js
* container.enable('my-key')
* // => container.repository['my-key'] === false
* ```
*/
enable(key: string | number): void;
/**
* ## container.disable
*
* Set the value of the given key to `false`.
*
* ### Usage
*
* ```js
* container.disable('my-key')
* // => container.repository['my-key'] === false
* ```
*/
disable(key: string | number): void;
/**
* ## container.isIndexed

@@ -447,0 +353,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

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