gs-collection
v1.0.35
Published
Instant Collection good for you
Downloads
9
Maintainers
Readme
GS-Collection
This module inspired by abalabahaha
Instalation (with npm)
npm i gs-collection@latest
Usage
GS-Collection is remastered version of @discordjs/collection, so if pro at @discordjs/collection may be you can use GS-Collection too.
Apart from being a Collection, you can also use mixin
to mix two different objects, getTypeOf
to get the type of all objects, baseObjectBase` to convert a data.
DJSCollection
imported from @discordjs/collection.instantLazy
imported from aio-get-all-files.
Sample Code
const { Collection } = require("gs-collection");
const coll = new Collection({
entries: [ /* ["a", "value"], ["b", "value"] */ ],
/**
* Now this must have a parameter definer
*
* @param {*} a you can to not provide type type of parameter
*/
baseObject: function logic(a) { /* logic */ } /* Can be a class or function */,
keyIndex: id" /* Index to get property to be key of an entry & Must be a string */
});
coll.add(false, { id: "1" }); // output: { "id": "1" }
coll.add(false, { id: "2" }); // output: { "id": "2" }
coll.add(false, { id: "3" }); // output: { "id": "2" }
coll.update({ id: "3", role: "Member" }); // output: { "old": { "id": "3" }, "updated": { "id": "3", "role": "Member" } }
coll.remove({ id: "1" }); // output: { "id": "1" }