Commit Graph

78 Commits

Author SHA1 Message Date
Crawl
b5dfb55923 docs: make collections more accessible in docs (#3907)
Fixes #3896
2020-03-08 19:27:42 +01:00
Crawl
c065156a88 chore: consistency/prettier (#3852)
* chore: consistency/prettier

* chore: rebase

* chore: rebase

* chore: include typings

* fix: include typings file in prettier lint-staged
2020-02-29 14:35:57 +01:00
1Computer1
dad0cd8e81 feat: external collection package (#2934)
* Use external collection package

* Complete typings

* Document properly base collection class

* Add clone since sort is now in-place

* Update for latest changes to package

* Fix whitespace

* Update docs link

* Oops

* Update Collection.js

* Update index.d.ts
2019-09-10 17:44:47 +02:00
Gus Caplan
42505b78c1 chore: add strict mode (#2974) 2018-12-03 15:19:10 -06:00
Souji
78c4be52c6 docs(Collection): clarify example for tap method (#2881)
* docs: clarify example for Collection#tap

* docs: wording improvement
2018-10-10 10:29:53 +02:00
Alex Hîncu
ce8a679a14 fix(Collection): use Symbol.species for creating derived collections (#2715) 2018-08-10 10:57:33 +02:00
1Computer1
8e0ea9aa16 Collection debug methods, remove deleteAll (#2577) 2018-08-09 14:25:07 +02:00
Amish Shah
98dc2df6d4 Revert "fix(Collection): use new this.constructor instead of new Collection (#2709)"
This reverts commit c10b4feeeb.
2018-08-07 19:08:51 +01:00
Alex Hîncu
c10b4feeeb fix(Collection): use new this.constructor instead of new Collection (#2709) 2018-08-07 18:08:49 +02:00
SpaceEEC
56a9d1ba3c docs(Collection): make findKey method show up in docs
Solved by moving the eslint-enable line below the method header.
2018-05-19 08:50:39 +02:00
1Computer1
a732402c95 refactor: remove unnecessary Collection methods and add Collection#partition (#2511)
* Rework collection

* Fix docs

* Remove (prop, value) behavior

* Add back thisArg

* Put examples on same line

* Revert map to return array

* Make examples less specific

* Add thisArg to sweep and partition
2018-05-14 01:15:43 -05:00
bdistin
7a3a4d1388 feat: add Collection#sweep() (#2528) 2018-05-04 02:27:59 -05:00
1Computer1
9f918199d2 feat: add Collection#tap (#2507)
* Add Collection#inspect

* No u

* Rename to tap

* Rename variable

* Do it here too
2018-05-04 02:08:32 -05:00
bdistin
17d2c2efb8 docs(Collection): fix spelling of 'behavior' (#2529) 2018-05-03 08:00:56 +02:00
Will Nelson
cf7dcba1a5 Add toJSON methods (#1859)
* tojson things

* fix client

* ignore private properties

* remove extra property descriptors

* handle primitive flattening

* remove unused import

* add toJSON to collections

* reduce stateful props

* state

* allow custom prop names when flattening

* fix client

* fix build

* fix flatten docs

* remove guild.available, cleanup permissions, remove arbitrary id reduction

* fix util import

* add valueOf as needed, update member props

* fix incorrect merge

* update permissionoverwrites and permissions

remove serialization of permissions in PermissionOverwrites#toJSON.
change Permissions#toJSON to serialize permissions, by default excluding
admin checks.

* change Permissions#toJSON to return the primitive

* Permissions#toJSON explicitly return bitfield
2018-03-01 23:00:21 -06:00
Kyra
a8172951d3 perf(Collection): Performance improvements (#2342)
* Update Collection.js

* ESLint
2018-02-16 10:19:30 +01:00
bdistin
4122db0275 Return undefined from Collection.find() / findKey() (#2260)
To be compliant with Array.find() / findIndex()
2018-01-16 01:24:19 +01:00
Isabella
0607720ec8 docs: improve documentation (#1898)
* improve channel documentation

* forgot some stuff

* another one

* im good at this

* i did a dum
2017-09-08 02:01:35 +02:00
iCrawl
a8df63ad1a docs: collection first, firstKey, last, lastKey
"count is negative" -> "amount is negative"
2017-09-05 18:04:18 +02:00
Robin B
e5ac8f34ee Collections: Negative amounts and fixes (#1889)
* feat(Collection): Negative amounts plus fixes and refactor

* fix(Collection): Fix result when supplying false boolean as amount
2017-09-05 11:31:33 +01:00
Cynthia Lin
3a503ef56e Fix code inconsistencies and redundancy in util/Collections.js. (#1884)
* Normalize undefined type checks in collections with typeof operators.

* Remove redundant number type checking in collections.

Number.isInteger() throws false for strings and any other types that aren't numbers.
2017-09-04 17:45:58 +02:00
Robin B
efbde07650 docs(Collection): Adjust exists documentation (#1876)
Since the return value of Collection#exists is basically just a boolean of Collection#find's result, the same documentation and arguments can and should be applied.
2017-09-03 12:00:36 +02:00
Évelyne Lachance
06f4c679d3 Add count optional argument to Collection methods (#1552)
* Add `count` optional argument to Collection methods

[NON-BREAKING CHANGE]
An optional `count` argument is added to the following methods:
- random() and randomKey()
- first() and firstKey()
- last() and lastKey()

If `count` is used, the method returns an array instead of only the value. Performance impact non-existent for existing code. Performance for returning an array has been measured and this is the fastest I could find (array[i] = value is faster than array.push()).

* Update Collection.js

Fixed spacing/line length errors according to suggestions by codacy/pr

* Fixed docs

Added proper `@returns {*|Array}` as the methods might return either. Also added params where missing (whoops)

* Further doc fixes

Per Crawl's comments, fixed (i + 1) spacing as well as fixed {Integer} to {number}

* random() and randomKey() fix

Per Hydra's comment, random() and randomKey() now ensures unique values.
I've also resolved potential issues with requesting a count higher than the collection size. A collection with 10 items will only ever return at most 10 items using the `count` property.

* Can I facepalm harder

Had wrong header comments ^_^

* Fixed for "values/value" and Omited

Also, added "Positive" integer check.

* looks like I "omitted" a change, there.

* Update Collection.js

* Update Collection.js

* Update Collection.js
2017-06-07 18:52:41 -04:00
Crawl
ac92d2cecc Improve docs a bit 2017-04-30 04:30:44 +02:00
Gus Caplan
a4e0af2e45 make positions for channels and roles nicer (#1211)
* make role calculated position nicer

* make channels sortable in a nice way too

* stupid git web rebase editor

* Update Guild.js

* Update Guild.js

* Update Guild.js

* Update Guild.js

* Update RESTMethods.js
2017-04-01 08:28:54 +02:00
Gus Caplan
dd3831fa1e Remove type error from Collection#exists() (#1320) 2017-03-30 11:01:07 -04:00
bdistin
25bb602d5a Add Collection.clone() (#1238)
* Add Collection.clone()

* More efficient cloning, and concat update

* Update Collection.js

* Update Collection.js
2017-03-01 04:41:36 -05:00
Gus Caplan
1e6abe587b no more (#1117) 2017-01-19 17:10:54 +00:00
Zack Campbell
b68283e57a Make _array & _keyArray non-enumerable (#1075)
Because Map has no enumerable properties
2017-01-08 11:59:45 +00:00
Amish Shah
fde3a976aa Revert "This expands the consistency of .find and .exists to include the id property" (#1074) 2017-01-08 10:17:10 +00:00
Jacob
2a668ac997 This expands the consistency of .find and .exists to include the id property (#1072)
* provide a more consistent api for .find

* remove random warning

* make code more concise
2017-01-08 09:02:44 +00:00
Schuyler Cebulskie
28ca83011c Implement missing Collection#reduce functionality 2016-12-24 01:59:14 -05:00
Alexander
264ee8e7f1 Equals updates (#987)
* Docs update

Changed the param names and param descriptions to be consistent.

* Added === comparison

Changed Presence.equals and Game.equals to first compare using ===

* Collection.equals fix

Now returns false when collection is undefined, instead of crashing
💯
2016-12-14 17:10:34 -05:00
Schuyler Cebulskie
bd00bc404c Make Collection#set/delete return the result of the super call, and clean up equals docs 2016-12-03 21:38:27 -05:00
Slamakans
a0b245bfe1 equals function added (#948)
Adds an equals function that checks for differing size and differing
key-value pairs, and takes into account the edge case for when there's
an entry for the key, but the value is undefined.
2016-12-03 21:34:26 -05:00
Schuyler Cebulskie
ac64f8bd23 Improve rest args docs 2016-11-24 11:22:13 -05:00
Schuyler Cebulskie
2bb5aa1fda Change Collection description 2016-11-20 18:05:01 -05:00
Schuyler Cebulskie
a80a64f8ce Update Collection docs some more 2016-11-20 17:59:54 -05:00
Schuyler Cebulskie
74ab72fdea Update Collection docs 2016-11-20 17:39:55 -05:00
Schuyler Cebulskie
bb3b709d6e Nothing to see here 👀 2016-11-13 01:13:13 -05:00
Schuyler Cebulskie
da9d1a3daf Don't mind me 2016-11-13 01:07:48 -05:00
Schuyler Cebulskie
ee3a03f707 Make Collection.find/exists error when using with IDs 2016-11-13 00:27:56 -05:00
Schuyler Cebulskie
b07a31d44e Change case of "function" 2016-11-12 21:07:22 -05:00
Schuyler Cebulskie
90304aa7d6 Fix loads of JSDoc type issues 2016-11-12 20:52:37 -05:00
Schuyler Cebulskie
a673a97441 Rephrase Collection.find/exists slightly 2016-10-30 22:28:06 -04:00
Schuyler Cebulskie
d7e1e1c0c9 Add warnings for Collection.find/exists 2016-10-30 22:22:16 -04:00
Schuyler Cebulskie
6baf43dc24 Add Collection.filterArray 2016-10-15 01:20:31 -04:00
Schuyler Cebulskie
93425c3979 Expand collection array caching 2016-10-04 19:10:29 -04:00
Schuyler Cebulskie
2c3c91fe41 Merge branch 'master' into indev 2016-10-04 19:02:09 -04:00
Slamakans
53f5c2cb52 Cache array and keyArray in Collection (#771)
* Cache array and keyArray in Collection

Cache array and keyArray in the Collection class to improve consecutive
calls of collection.random() by around 400,000%, I think lel.

The speed decrease (I assume) compared to the previous version when
calling after it has changed is most likely negligible.

* Fix for ESLint

I think this fixes it.
2016-10-04 18:53:26 -04:00