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

@discordjs/collection

Package Overview
Dependencies
Maintainers
2
Versions
1195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@discordjs/collection - npm Package Compare versions

Comparing version 0.1.6 to 0.2.0

80

dist/index.d.ts

@@ -14,8 +14,5 @@ export interface CollectionConstructor {

*/
declare class Collection<K, V> extends Map<K, V> {
private _array;
private _keyArray;
export declare class Collection<K, V> extends Map<K, V> {
static readonly default: typeof Collection;
['constructor']: typeof Collection;
constructor(entries?: ReadonlyArray<readonly [K, V]> | null);
['constructor']: CollectionConstructor;
/**

@@ -57,17 +54,13 @@ * Identical to [Map.get()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get).

/**
* Creates an ordered array of the values of this collection, and caches it internally. The array will only be
* reconstructed if an item is added to or removed from the collection, or if you change the length of the array
* itself. If you don't want this caching behavior, use `[...collection.values()]` or
* `Array.from(collection.values())` instead.
* @returns {Array}
* Checks if all of the elements exist in the collection.
* @param {...*} keys - The keys of the elements to check for
* @returns {boolean} `true` if all of the elements exist, `false` if at least one does not exist.
*/
array(): V[];
hasAll(...keys: K[]): boolean;
/**
* Creates an ordered array of the keys of this collection, and caches it internally. The array will only be
* reconstructed if an item is added to or removed from the collection, or if you change the length of the array
* itself. If you don't want this caching behavior, use `[...collection.keys()]` or
* `Array.from(collection.keys())` instead.
* @returns {Array}
* Checks if any of the elements exist in the collection.
* @param {...*} keys - The keys of the elements to check for
* @returns {boolean} `true` if any of the elements exist, `false` if none exist.
*/
keyArray(): K[];
hasAny(...keys: K[]): boolean;
/**

@@ -90,4 +83,3 @@ * Obtains the first value(s) in this collection.

/**
* Obtains the last value(s) in this collection. This relies on {@link Collection#array}, and thus the caching
* mechanism applies here as well.
* Obtains the last value(s) in this collection.
* @param {number} [amount] Amount of values to obtain from the end

@@ -100,4 +92,3 @@ * @returns {*|Array<*>} A single value if no amount is provided or an array of values, starting from the start if

/**
* Obtains the last key(s) in this collection. This relies on {@link Collection#keyArray}, and thus the caching
* mechanism applies here as well.
* Obtains the last key(s) in this collection.
* @param {number} [amount] Amount of keys to obtain from the end

@@ -110,4 +101,3 @@ * @returns {*|Array<*>} A single key if no amount is provided or an array of keys, starting from the start if

/**
* Obtains unique random value(s) from this collection. This relies on {@link Collection#array}, and thus the caching
* mechanism applies here as well.
* Obtains unique random value(s) from this collection.
* @param {number} [amount] Amount of values to obtain randomly

@@ -119,4 +109,3 @@ * @returns {*|Array<*>} A single value if no amount is provided or an array of values

/**
* Obtains unique random key(s) from this collection. This relies on {@link Collection#keyArray}, and thus the caching
* mechanism applies here as well.
* Obtains unique random key(s) from this collection.
* @param {number} [amount] Amount of keys to obtain randomly

@@ -138,4 +127,6 @@ * @returns {*|Array<*>} A single key if no amount is provided or an array

*/
find<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): V2 | undefined;
find(fn: (value: V, key: K, collection: this) => boolean): V | undefined;
find<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): V | undefined;
find<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): V2 | undefined;
find<This>(fn: (this: This, value: V, key: K, collection: this) => boolean, thisArg: This): V | undefined;
/**

@@ -150,4 +141,6 @@ * Searches for the key of a single item where the given function returns a truthy value. This behaves like

*/
findKey<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): K2 | undefined;
findKey(fn: (value: V, key: K, collection: this) => boolean): K | undefined;
findKey<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): K | undefined;
findKey<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): K2 | undefined;
findKey<This>(fn: (this: This, value: V, key: K, collection: this) => boolean, thisArg: This): K | undefined;
/**

@@ -170,4 +163,8 @@ * Removes items that satisfy the provided filter function.

*/
filter(fn: (value: V, key: K, collection: this) => boolean): this;
filter<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): this;
filter<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): Collection<K2, V>;
filter<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): Collection<K, V2>;
filter(fn: (value: V, key: K, collection: this) => boolean): Collection<K, V>;
filter<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): Collection<K2, V>;
filter<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): Collection<K, V2>;
filter<This>(fn: (this: This, value: V, key: K, collection: this) => boolean, thisArg: This): Collection<K, V>;
/**

@@ -181,4 +178,8 @@ * Partitions the collection into two collections where the first collection

*/
partition(fn: (value: V, key: K, collection: this) => boolean): [this, this];
partition<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): [this, this];
partition<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
partition<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
partition(fn: (value: V, key: K, collection: this) => boolean): [Collection<K, V>, Collection<K, V>];
partition<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
partition<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
partition<This>(fn: (this: This, value: V, key: K, collection: this) => boolean, thisArg: This): [Collection<K, V>, Collection<K, V>];
/**

@@ -232,4 +233,8 @@ * Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to

*/
every<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): this is Collection<K2, V>;
every<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): this is Collection<K, V2>;
every(fn: (value: V, key: K, collection: this) => boolean): boolean;
every<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): boolean;
every<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): this is Collection<K2, V>;
every<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): this is Collection<K, V2>;
every<This>(fn: (this: This, value: V, key: K, collection: this) => boolean, thisArg: This): boolean;
/**

@@ -278,3 +283,3 @@ * Applies a function to produce a single value. Identical in behavior to

*/
clone(): this;
clone(): Collection<K, V>;
/**

@@ -286,3 +291,3 @@ * Combines this collection with others into a new collection. None of the source collections are modified.

*/
concat(...collections: Collection<K, V>[]): this;
concat(...collections: Collection<K, V>[]): Collection<K, V>;
/**

@@ -306,3 +311,3 @@ * Checks if this collection shares identical items with another.

*/
sort(compareFunction?: (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number): this;
sort(compareFunction?: Comparator<K, V>): this;
/**

@@ -330,5 +335,6 @@ * The intersect method returns a new structure containing items where the keys are present in both original structures.

*/
sorted(compareFunction?: (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number): this;
sorted(compareFunction?: Comparator<K, V>): Collection<K, V>;
private static defaultSort;
}
export { Collection };
export declare type Comparator<K, V> = (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number;
export default Collection;
{
"name": "@discordjs/collection",
"version": "0.1.6",
"description": "Utility data structure used in Discord.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"lint": "eslint src --ext .ts",
"prebuild": "npm run lint",
"build": "rimraf dist/ && tsc",
"pretest": "npm run build",
"test": "node test/index.js",
"docs": "docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml --output docs/docs.json",
"docs:test": "docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml"
},
"repository": {
"type": "git",
"url": "git+https://github.com/discordjs/collection.git"
},
"keywords": [
"map",
"collection",
"utility"
],
"author": "Amish Shah <amishshah.2k@gmail.com>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/discordjs/collection/issues"
},
"homepage": "https://github.com/discordjs/collection#readme",
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"@babel/preset-typescript": "^7.8.3",
"@types/node": "^13.7.4",
"@typescript-eslint/eslint-plugin": "^2.21.0",
"@typescript-eslint/parser": "^2.21.0",
"discord.js-docgen": "discordjs/docgen#ts-patch",
"eslint": "^6.8.0",
"eslint-config-marine": "^6.0.0",
"jsdoc-babel": "^0.5.0",
"rimraf": "^3.0.2",
"typescript": "^3.8.2"
},
"eslintConfig": {
"extends": "marine/node"
}
"name": "@discordjs/collection",
"version": "0.2.0",
"description": "Utility data structure used in Discord.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"lint": "eslint test src --ext .ts",
"lint:fix": "eslint test src --ext .ts --fix",
"prebuild": "npm run lint",
"build": "rimraf dist/ && tsc",
"pretest": "npm run build",
"test": "jest",
"docs": "docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml --output docs/docs.json",
"docs:test": "docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml"
},
"repository": {
"type": "git",
"url": "git+https://github.com/discordjs/collection.git"
},
"keywords": [
"map",
"collection",
"utility"
],
"files": [
"!**/*.ts",
"**/*.d.ts",
"!package-lock.json"
],
"author": "Amish Shah <amishshah.2k@gmail.com>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/discordjs/collection/issues"
},
"homepage": "https://github.com/discordjs/collection#readme",
"engines": {
"node": ">=14.0.0"
},
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/preset-typescript": "^7.12.7",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-angular": "^11.0.0",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.21",
"@typescript-eslint/eslint-plugin": "^4.13.0",
"@typescript-eslint/parser": "^4.13.0",
"discord.js-docgen": "discordjs/docgen#ts-patch",
"eslint": "^7.17.0",
"eslint-config-marine": "^8.1.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.1",
"husky": "^4.3.7",
"jest": "^26.6.3",
"jsdoc-babel": "^0.5.0",
"lint-staged": "^10.5.3",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"typescript": "^4.1.3"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.{ts,js}": [
"eslint --fix"
],
"*.{json,yml,yaml}": [
"prettier --write"
]
},
"commitlint": {
"extends": [
"@commitlint/config-angular"
],
"rules": {
"type-enum": [
2,
"always",
[
"chore",
"build",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
"types",
"wip",
"src"
]
]
}
}
}

Sorry, the diff of this file is too big to display

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