Socket
Socket
Sign inDemoInstall

@supercharge/collections

Package Overview
Dependencies
1
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

6

CHANGELOG.md
# Changelog
## [2.1.0](https://github.com/supercharge/collections/compare/v2.0.0...v2.1.0) - 2020-06-30
### Added
- `count` method
## [2.0.0](https://github.com/supercharge/collections/compare/v1.13.0...v2.0.0) - 2020-05-21

@@ -4,0 +10,0 @@

17

dist/collection-proxy.d.ts

@@ -64,5 +64,4 @@ export declare class CollectionProxy {

/**
* Creates a new collection containing the
* concatenated items of the original
* collection with the new `items`.
* Creates a new collection containing the concatenated items
* of the original collection with the new `items`.
*

@@ -75,2 +74,12 @@ * @param {*} items

/**
* Counts the items in the collection. By default, it behaves like an alias
* for the `size()` method counting each individual item. The `callback`
* function allows you to count a subset of items in the collection.
*
* @param {Function} callback
*
* @returns {Number}
*/
count(callback?: Function): Promise<number>;
/**
* Removes all values from the collection that are present in the given array.

@@ -414,3 +423,3 @@ *

*/
_enqueue(method: string, callback?: Function, data?: any): this;
private enqueue;
/**

@@ -417,0 +426,0 @@ * Creates a “thenable” allowing you to await collection

@@ -37,3 +37,3 @@ 'use strict';

async avg() {
return this._enqueue('avg');
return this.enqueue('avg');
}

@@ -49,3 +49,3 @@ /**

chunk(size) {
return this._enqueue('chunk', undefined, size);
return this.enqueue('chunk', undefined, size);
}

@@ -66,3 +66,3 @@ /**

collapse() {
return this._enqueue('collapse');
return this.enqueue('collapse');
}

@@ -77,8 +77,7 @@ /**

compact() {
return this._enqueue('compact');
return this.enqueue('compact');
}
/**
* Creates a new collection containing the
* concatenated items of the original
* collection with the new `items`.
* Creates a new collection containing the concatenated items
* of the original collection with the new `items`.
*

@@ -90,5 +89,17 @@ * @param {*} items

concat(...items) {
return this.clone()._enqueue('concat', undefined, items);
return this.clone().enqueue('concat', undefined, items);
}
/**
* Counts the items in the collection. By default, it behaves like an alias
* for the `size()` method counting each individual item. The `callback`
* function allows you to count a subset of items in the collection.
*
* @param {Function} callback
*
* @returns {Number}
*/
async count(callback) {
return this.enqueue('count', callback).all();
}
/**
* Removes all values from the collection that are present in the given array.

@@ -101,3 +112,3 @@ *

diff(items) {
return this._enqueue('diff', undefined, items);
return this.enqueue('diff', undefined, items);
}

@@ -114,3 +125,3 @@ /**

async every(callback) {
return this._enqueue('every', callback);
return this.enqueue('every', callback);
}

@@ -127,3 +138,3 @@ /**

filter(callback) {
return this._enqueue('filter', callback);
return this.enqueue('filter', callback);
}

@@ -140,3 +151,3 @@ /**

async find(callback) {
return this._enqueue('find', callback);
return this.enqueue('find', callback);
}

@@ -153,3 +164,3 @@ /**

async first(callback) {
return this._enqueue('first', callback).all();
return this.enqueue('first', callback).all();
}

@@ -167,3 +178,3 @@ /**

flatMap(callback) {
return this._enqueue('flatMap', callback);
return this.enqueue('flatMap', callback);
}

@@ -177,3 +188,3 @@ /**

async forEach(callback) {
return this._enqueue('forEach', callback).all();
return this.enqueue('forEach', callback).all();
}

@@ -188,3 +199,3 @@ /**

async groupBy(key) {
return this._enqueue('groupBy', undefined, key).all();
return this.enqueue('groupBy', undefined, key).all();
}

@@ -201,3 +212,3 @@ /**

async has(callback) {
return this._enqueue('has', callback);
return this.enqueue('has', callback);
}

@@ -210,3 +221,3 @@ /**

async hasDuplicates() {
return this._enqueue('hasDuplicates');
return this.enqueue('hasDuplicates');
}

@@ -221,3 +232,3 @@ /**

intersect(items) {
return this._enqueue('intersect', undefined, items);
return this.enqueue('intersect', undefined, items);
}

@@ -230,3 +241,3 @@ /**

async isEmpty() {
return this._enqueue('isEmpty');
return this.enqueue('isEmpty');
}

@@ -239,3 +250,3 @@ /**

async isNotEmpty() {
return this._enqueue('isNotEmpty');
return this.enqueue('isNotEmpty');
}

@@ -251,3 +262,3 @@ /**

async join(separator) {
return this._enqueue('join', undefined, separator);
return this.enqueue('join', undefined, separator);
}

@@ -264,3 +275,3 @@ /**

async last(callback) {
return this._enqueue('last', callback).all();
return this.enqueue('last', callback).all();
}

@@ -277,3 +288,3 @@ /**

map(callback) {
return this._enqueue('map', callback);
return this.enqueue('map', callback);
}

@@ -286,3 +297,3 @@ /**

async max() {
return this._enqueue('max');
return this.enqueue('max');
}

@@ -295,3 +306,3 @@ /**

async median() {
return this._enqueue('median');
return this.enqueue('median');
}

@@ -304,3 +315,3 @@ /**

async min() {
return this._enqueue('min');
return this.enqueue('min');
}

@@ -315,3 +326,3 @@ /**

pluck(keys) {
return this._enqueue('pluck', undefined, keys).collapse();
return this.enqueue('pluck', undefined, keys).collapse();
}

@@ -326,3 +337,3 @@ /**

this.splice(-1, 1);
return collection._enqueue('pop');
return collection.enqueue('pop');
}

@@ -337,3 +348,3 @@ /**

push(...items) {
return this._enqueue('push', undefined, items);
return this.enqueue('push', undefined, items);
}

@@ -351,3 +362,3 @@ /**

async reduce(reducer, initial) {
return this._enqueue('reduce', reducer, initial).all();
return this.enqueue('reduce', reducer, initial).all();
}

@@ -365,3 +376,3 @@ /**

async reduceRight(reducer, initial) {
return this._enqueue('reduceRight', reducer, initial).all();
return this.enqueue('reduceRight', reducer, initial).all();
}

@@ -378,3 +389,3 @@ /**

reject(callback) {
return this._enqueue('reject', callback);
return this.enqueue('reject', callback);
}

@@ -388,3 +399,3 @@ /**

reverse() {
return this.clone()._enqueue('reverse');
return this.clone().enqueue('reverse');
}

@@ -399,3 +410,3 @@ /**

this.splice(0, 1);
return collection._enqueue('shift').all();
return collection.enqueue('shift').all();
}

@@ -408,3 +419,3 @@ /**

async size() {
return this._enqueue('size').all();
return this.enqueue('size').all();
}

@@ -422,3 +433,3 @@ /**

slice(start, limit) {
return this._enqueue('slice', undefined, { start, limit });
return this.enqueue('slice', undefined, { start, limit });
}

@@ -438,3 +449,3 @@ /**

const collection = this.clone().slice(start, limit);
this._enqueue('splice', undefined, { start, limit, inserts });
this.enqueue('splice', undefined, { start, limit, inserts });
return collection;

@@ -452,3 +463,3 @@ }

async some(callback) {
return this._enqueue('some', callback).all();
return this.enqueue('some', callback).all();
}

@@ -463,3 +474,3 @@ /**

sort(comparator) {
return this.clone()._enqueue('sort', comparator);
return this.clone().enqueue('sort', comparator);
}

@@ -472,3 +483,3 @@ /**

async sum() {
return this._enqueue('sum').all();
return this.enqueue('sum').all();
}

@@ -499,3 +510,3 @@ /**

const collection = this.take(limit);
this._enqueue('takeAndRemove', undefined, limit);
this.enqueue('takeAndRemove', undefined, limit);
return collection;

@@ -509,3 +520,3 @@ }

tap(callback) {
return this._enqueue('tap', callback);
return this.enqueue('tap', callback);
}

@@ -518,3 +529,3 @@ /**

async toJSON() {
return this._enqueue('toJSON').all();
return this.enqueue('toJSON').all();
}

@@ -539,3 +550,3 @@ /**

unique(key) {
return this._enqueue('unique', undefined, key);
return this.enqueue('unique', undefined, key);
}

@@ -548,3 +559,3 @@ /**

unshift(...items) {
return this._enqueue('unshift', undefined, items);
return this.enqueue('unshift', undefined, items);
}

@@ -561,3 +572,3 @@ /**

*/
_enqueue(method, callback, data) {
enqueue(method, callback, data) {
this.callChain.enqueue({ method, callback, data });

@@ -564,0 +575,0 @@ return this;

@@ -51,2 +51,12 @@ export declare class Collection {

/**
* Counts the items in the collection. By default, it behaves like an alias
* for the `size()` method counting each individual item. The `callback`
* function allows you to count a subset of items in the collection.
*
* @param {Function} callback
*
* @returns {Number}
*/
count(callback?: Function): Promise<number>;
/**
* Removes all values from the collection that are present in the given array.

@@ -53,0 +63,0 @@ *

@@ -71,2 +71,18 @@ 'use strict';

/**
* Counts the items in the collection. By default, it behaves like an alias
* for the `size()` method counting each individual item. The `callback`
* function allows you to count a subset of items in the collection.
*
* @param {Function} callback
*
* @returns {Number}
*/
async count(callback) {
if (!callback) {
return this.size();
}
const filtered = await this.filter(callback);
return filtered.length;
}
/**
* Removes all values from the collection that are present in the given array.

@@ -73,0 +89,0 @@ *

{
"name": "@supercharge/collections",
"description": "Supercharge collections",
"version": "2.0.0",
"author": "Marcus Pöhls <marcus@futurestud.io>",
"version": "2.1.0",
"author": "Marcus Pöhls <marcus@superchargejs.com>",
"bugs": {

@@ -19,3 +19,3 @@ "url": "https://github.com/supercharge/collections/issues"

"eslint-config-standard": "~14.1.1",
"eslint-config-standard-with-typescript": "~17.0.0",
"eslint-config-standard-with-typescript": "~16.0.0",
"eslint-plugin-import": "~2.20.2",

@@ -26,3 +26,3 @@ "eslint-plugin-node": "~11.1.0",

"sinon": "~8.1.1",
"typescript": "~3.9.3"
"typescript": "~3.9.5"
},

@@ -29,0 +29,0 @@ "engines": {

@@ -11,3 +11,3 @@ <div align="center">

<p>
<strong><code>async/await-ready</code></strong> array & collection utilities for Node.js
<strong><code>async/await-ready</code></strong> array methods for Node.js
</p>

@@ -14,0 +14,0 @@ <br/>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc