@roots/container
Advanced tools
Comparing version 4.7.0-10 to 4.7.0-next.11
"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")); | ||
/** | ||
* @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.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; | ||
var Container_1 = require("./Container"); | ||
Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return Container_1.Container; } }); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
/** | ||
* `@roots/container` is a utility to make working with collections of data simple and chainable. | ||
* | ||
* @packageDocumentation | ||
*/ | ||
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; } }); | ||
const Container_1 = require("./Container"); | ||
Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return Container_1.Container; } }); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@roots/container", | ||
"version": "4.7.0-10", | ||
"version": "4.7.0-next.11", | ||
"description": "Collections utility", | ||
@@ -13,4 +13,8 @@ "homepage": "https://roots.io/bud", | ||
{ | ||
"name": "Kelly Mears", | ||
"name": "kellymears", | ||
"url": "https://github.com/kellymears" | ||
}, | ||
{ | ||
"name": "QWp6t", | ||
"url": "https://github.com/QWp6t" | ||
} | ||
@@ -65,6 +69,4 @@ ], | ||
"devDependencies": { | ||
"@types/eslint": "7.28.0", | ||
"@types/node": "15.14.1", | ||
"eslint": "7.31.0", | ||
"type-fest": "1.2.2" | ||
"type-fest": "2.0.0" | ||
}, | ||
@@ -71,0 +73,0 @@ "dependencies": { |
@@ -10,7 +10,10 @@ <p align="center"> | ||
/> | ||
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Froots%2Fbud?ref=badge_small" alt="FOSSA Status"> | ||
<img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Froots%2Fbud.svg?type=small"/> | ||
</a> | ||
<a href="https://www.npmjs.com/package/@roots/bud"> | ||
<img src="https://img.shields.io/npm/v/@roots/bud.svg?color=%23525ddc&style=flat-square" /> | ||
</a> | ||
<a href="https://codeclimate.com/github/roots/bud-support/maintainability"> | ||
<img src="https://img.shields.io/codeclimate/maintainability/roots/bud-support?color=%23525ddc&style=flat-square" /> | ||
<a href="https://codecov.io/gh/roots/bud"> | ||
<img src="https://codecov.io/gh/roots/bud/branch/next/graph/badge.svg?token=DRJ28OD8XD"/> | ||
</a> | ||
@@ -25,2 +28,3 @@ <a href="https://twitter.com/rootswp"> | ||
<h1 align="center"> | ||
@@ -27,0 +31,0 @@ <strong>@roots/container</strong> |
@@ -1,504 +0,3 @@ | ||
import { ValueOf } from 'type-fest'; | ||
/** | ||
* Indexed container value store. | ||
*/ | ||
export declare type Repository = { | ||
[key: string]: any; | ||
}; | ||
/** | ||
* @roots/container | ||
*/ | ||
export declare class Container<I = any> { | ||
/** | ||
* Identify | ||
*/ | ||
ident: '@roots/container'; | ||
/** | ||
* The container store | ||
*/ | ||
repository: any; | ||
/** | ||
* Class constructor | ||
*/ | ||
constructor(repository?: I); | ||
/** | ||
* ## container.all | ||
* | ||
* Does the same thing as container.all | ||
* | ||
* ### Usage | ||
* | ||
* ```js | ||
* container.all() | ||
* ``` | ||
*/ | ||
all(): any; | ||
/** | ||
* ## container.setStore | ||
* | ||
* Replace the store with an all new set of values | ||
* | ||
* ### Usage | ||
* | ||
* ```js | ||
* container.setStore({ | ||
* new: ['store', 'contents'], | ||
* }) | ||
* ``` | ||
*/ | ||
setStore(repository: Repository): this; | ||
/** | ||
* ## container.mergeStore | ||
* | ||
* Merge values onto the container store. | ||
* | ||
* ### Usage | ||
* | ||
* ```js | ||
* container.mergeStore({test: 'foo'}) | ||
* ``` | ||
*/ | ||
mergeStore(values: Repository): 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: (value: any) => any): any; | ||
/** | ||
* ## container.mutateStore | ||
* | ||
* Mutate the container store. | ||
* | ||
* ### Usage | ||
* | ||
* ```js | ||
* container.mutate('key', currentValue => modifiedValue) | ||
* ``` | ||
*/ | ||
mutateStore(mutationFn: (value?: I) => I): 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<T = any>(key: string | number): T; | ||
/** | ||
* ## 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<T = any>(key?: string | number): [string, ValueOf<T>][]; | ||
/** | ||
* ## 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: [string, any][]): this; | ||
/** | ||
* ## container.withEntries | ||
* | ||
* Use each value as parameters in a supplied callback | ||
* | ||
* ### Usage | ||
* | ||
* ```js | ||
* container.withEntries('key', (key, value) => doSomething) | ||
* ``` | ||
*/ | ||
each(key: string | number, callFn: (key: any, value: any) => void): this; | ||
/** | ||
* ## container.every | ||
* | ||
* Use each value as parameters in a supplied callback | ||
* | ||
* ### Usage | ||
* | ||
* ```js | ||
* container.withEntries('key', (key, value) => doSomething) | ||
* ``` | ||
*/ | ||
every(fn: (key: string | number, value: any) => any): this; | ||
/** | ||
* Find | ||
*/ | ||
findKey(...searchItem: any): any; | ||
/** | ||
* Find in container item | ||
*/ | ||
findKeyIn(key: string | number, ...searchItem: any[]): any; | ||
/** | ||
* ## 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?: string): any[]; | ||
/** | ||
* ## 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?: string): string[]; | ||
/** | ||
* ## 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?: string): Map<string, any>; | ||
/** | ||
* ## container.set | ||
* | ||
* Set a value on a container item. | ||
* | ||
* ### Usage | ||
* | ||
* ```js | ||
* container.set('key', value) | ||
* ``` | ||
*/ | ||
set(key: string | number, value: any): 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: string | number, mutationFn: (value?: any) => any): any; | ||
/** | ||
* ## container.mutate | ||
* | ||
* Mutate a container item. | ||
* | ||
* ### Usage | ||
* | ||
* ```js | ||
* container.mutate('key', currentValue => modifiedValue) | ||
* ``` | ||
*/ | ||
mutate(key: string | number, mutationFn: (value?: any) => any): 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: string | number, value: any): 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: string | number): boolean; | ||
/** | ||
* ## container.delete | ||
* | ||
* Delete an entry from the repository | ||
* | ||
* ### Usage | ||
* | ||
* ```js | ||
* container.remove('my-key') | ||
* // Remove container.repository['my-key'] | ||
* ``` | ||
*/ | ||
remove(key: string | number): 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: string | number, value: any): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
/** | ||
* ## 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?: string | number): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
/** | ||
* ## container.isNull | ||
* | ||
* Return true if object is null. | ||
* | ||
* ### Usage | ||
* | ||
* ```js | ||
* container.isNull('my-key') | ||
* // True if container.repository['my-key'] is null | ||
* ``` | ||
*/ | ||
isNull(key: string | number): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
/** | ||
* ## 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: string | number): boolean; | ||
} | ||
export { Container } from './Container'; | ||
export { Repository } from './Repository'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,8 @@ | ||
export { Container } from './Container/index'; | ||
/** | ||
* `@roots/container` is a utility to make working with collections of data simple and chainable. | ||
* | ||
* @packageDocumentation | ||
*/ | ||
import { Container, Repository } from './Container'; | ||
export { 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
172482
2
29
1509
70
1