@supercharge/collections
Advanced tools
Comparing version 3.0.0 to 3.1.0
# Changelog | ||
## [3.1.0](https://github.com/supercharge/collections/compare/v3.0.0...v3.1.0) - 2020-12-02 | ||
### Updated | ||
- bump dependencies | ||
- change typings to allow single values and arrays (`T | T[]`) when creating collections | ||
## [3.0.0](https://github.com/supercharge/collections/compare/v2.4.0...v3.0.0) - 2020-09-03 | ||
@@ -4,0 +11,0 @@ |
@@ -145,3 +145,3 @@ export declare class Collection { | ||
* represented by `callback` or if the collection | ||
* satisfies the given `callback` testing function. | ||
* satisfies the given `callback` testing function. Alias of `includes`. | ||
* | ||
@@ -160,2 +160,12 @@ * @param {Function} callback | ||
/** | ||
* Determines whether the the collection contains the item | ||
* represented by `callback` or if the collection | ||
* satisfies the given `callback` testing function. Alias of `has`. | ||
* | ||
* @param {Function} callback | ||
* | ||
* @returns {Boolean} | ||
*/ | ||
includes(callback: Function): Promise<boolean>; | ||
/** | ||
* Creates an array of unique values that are included in both given array. | ||
@@ -162,0 +172,0 @@ * |
@@ -215,3 +215,3 @@ 'use strict'; | ||
* represented by `callback` or if the collection | ||
* satisfies the given `callback` testing function. | ||
* satisfies the given `callback` testing function. Alias of `includes`. | ||
* | ||
@@ -237,2 +237,14 @@ * @param {Function} callback | ||
/** | ||
* Determines whether the the collection contains the item | ||
* represented by `callback` or if the collection | ||
* satisfies the given `callback` testing function. Alias of `has`. | ||
* | ||
* @param {Function} callback | ||
* | ||
* @returns {Boolean} | ||
*/ | ||
async includes(callback) { | ||
return this.has(callback); | ||
} | ||
/** | ||
* Creates an array of unique values that are included in both given array. | ||
@@ -239,0 +251,0 @@ * |
@@ -10,3 +10,3 @@ import { SyncCollection } from './sync-collection'; | ||
*/ | ||
declare const collect: <T>(collection: T[]) => SyncCollection<T>; | ||
declare const collect: <T>(collection: T | T[]) => SyncCollection<T>; | ||
export = collect; |
@@ -185,3 +185,3 @@ interface QueueItem { | ||
* represented by `callback` or if the collection | ||
* satisfies the given `callback` testing function. | ||
* satisfies the given `callback` testing function. Alias of `has`. | ||
* | ||
@@ -200,2 +200,12 @@ * @param {Function} callback | ||
/** | ||
* Determines whether the the collection contains the item | ||
* represented by `callback` or if the collection | ||
* satisfies the given `callback` testing function. Alias of `has`. | ||
* | ||
* @param {Function} callback | ||
* | ||
* @returns {Boolean} | ||
*/ | ||
includes(callback: (value: T, index: number, items: T[]) => boolean | Promise<boolean>): Promise<boolean>; | ||
/** | ||
* Creates an array of unique values that are included in both given array | ||
@@ -202,0 +212,0 @@ * |
@@ -208,3 +208,3 @@ 'use strict'; | ||
* represented by `callback` or if the collection | ||
* satisfies the given `callback` testing function. | ||
* satisfies the given `callback` testing function. Alias of `has`. | ||
* | ||
@@ -227,2 +227,14 @@ * @param {Function} callback | ||
/** | ||
* Determines whether the the collection contains the item | ||
* represented by `callback` or if the collection | ||
* satisfies the given `callback` testing function. Alias of `has`. | ||
* | ||
* @param {Function} callback | ||
* | ||
* @returns {Boolean} | ||
*/ | ||
async includes(callback) { | ||
return this.has(callback); | ||
} | ||
/** | ||
* Creates an array of unique values that are included in both given array | ||
@@ -229,0 +241,0 @@ * |
@@ -12,3 +12,3 @@ import { PendingAsyncCollection } from './pending-async-collection'; | ||
*/ | ||
constructor(items: T[]); | ||
constructor(items: T | T[]); | ||
/** | ||
@@ -170,4 +170,4 @@ * Returns the array of items. | ||
*/ | ||
forEach(action: (value: T, index: number, items: T[]) => void): SyncCollection<T>; | ||
forEach(action: (value: T, index: number, items: T[]) => Promise<void>): PendingAsyncCollection<T>; | ||
forEach(action: (value: T, index: number, items: T[]) => void): void; | ||
forEach(action: (value: T, index: number, items: T[]) => Promise<void>): Promise<void>; | ||
/** | ||
@@ -184,3 +184,3 @@ * Group the collection items into arrays using the given `key`. | ||
* represented by `callback` or if the collection | ||
* satisfies the given `callback` testing function. | ||
* satisfies the given `callback` testing function. Alias of `includes`. | ||
* | ||
@@ -200,2 +200,13 @@ * @param {Function} predicate | ||
/** | ||
* Determines whether the the collection contains the item | ||
* represented by `callback` or if the collection | ||
* satisfies the given `callback` testing function. Alias of `has`. | ||
* | ||
* @param {Function} predicate | ||
* | ||
* @returns {Boolean} | ||
*/ | ||
includes(predicate: (value: T, index: number, items: T[]) => any): boolean; | ||
includes(predicate: (value: T, index: number, items: T[]) => Promise<any>): Promise<boolean>; | ||
/** | ||
* Creates an array of unique values that are included in both given array | ||
@@ -202,0 +213,0 @@ * |
@@ -153,5 +153,3 @@ 'use strict'; | ||
? this.proxy('forEach', action).all() | ||
: goodies_1.tap(this, () => { | ||
this.items.forEach(action); | ||
}); | ||
: this.items.forEach(action); | ||
} | ||
@@ -196,2 +194,5 @@ /** | ||
} | ||
includes(predicate) { | ||
return this.has(predicate); | ||
} | ||
/** | ||
@@ -198,0 +199,0 @@ * Creates an array of unique values that are included in both given array |
{ | ||
"name": "@supercharge/collections", | ||
"description": "Supercharge collections", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"author": "Marcus Pöhls <marcus@superchargejs.com>", | ||
@@ -15,14 +15,14 @@ "bugs": { | ||
"@hapi/code": "~8.0.2", | ||
"@hapi/lab": "~23.0.0", | ||
"@hapi/lab": "~24.1.0", | ||
"@supercharge/tsconfig": "~1.0.0", | ||
"@typescript-eslint/eslint-plugin": "~4.0.1", | ||
"eslint": "~7.8.1", | ||
"eslint-config-standard": "~14.1.1", | ||
"@typescript-eslint/eslint-plugin": "~4.9.0", | ||
"eslint": "~7.14.0", | ||
"eslint-config-standard": "~16.0.2", | ||
"eslint-config-standard-with-typescript": "~19.0.1", | ||
"eslint-plugin-import": "~2.22.0", | ||
"eslint-plugin-import": "~2.22.1", | ||
"eslint-plugin-node": "~11.1.0", | ||
"eslint-plugin-promise": "~4.2.1", | ||
"eslint-plugin-standard": "~4.0.1", | ||
"sinon": "~9.0.3", | ||
"typescript": "~4.0.2" | ||
"eslint-plugin-standard": "~4.1.0", | ||
"sinon": "~9.2.1", | ||
"typescript": "~4.1.2" | ||
}, | ||
@@ -29,0 +29,0 @@ "engines": { |
171438
5350