Commit Graph

62 Commits

Author SHA1 Message Date
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
Schuyler Cebulskie
0bcca7bb55 Add Collection.concat 2016-09-27 20:47:12 -04:00
Kelvin Wu
bd465108a7 Fix return type in docs. 2016-09-24 11:58:51 -04:00
Schuyler Cebulskie
737ad8e92b Slightly improve some Collection docs 2016-09-22 21:36:06 -04:00
Schuyler Cebulskie
9cd249342b Teensy reorganisation 2016-09-12 21:40:15 -04:00
Schuyler Cebulskie
ac85ffce4b Add Collection.keyArray/firstKey/lastKey/randomKey 2016-09-12 21:39:41 -04:00
Schuyler Cebulskie
84b33f9b66 Add Collection.reduce 2016-09-12 21:33:29 -04:00
Schuyler Cebulskie
fba3508079 Add a little more detail about value 2016-09-12 02:52:32 -04:00
Schuyler Cebulskie
2aae20085b Key -> Property 2016-09-12 02:20:53 -04:00
Schuyler Cebulskie
e24c1e55a0 Remove wholly unnecessary example 2016-09-12 00:33:24 -04:00
Schuyler Cebulskie
7457985e60 Fix Collection.findKey doc link 2016-09-12 00:28:27 -04:00
Schuyler Cebulskie
95605863c7 Add Collection.findKey 2016-09-12 00:26:02 -04:00
Schuyler Cebulskie
ac1f5f32e2 Add Collection.find with function 2016-09-12 00:18:21 -04:00
Schuyler Cebulskie
47d71d32f3 Make grammer gooder 2016-09-11 01:40:37 -04:00
Schuyler Cebulskie
594836b1bf Rewrite Collection.map/filter, and add some/every 2016-09-08 02:26:28 -04:00
Amish Shah
7b870d13de Fix collection.find/findAll docs 2016-09-04 21:41:19 +01:00
Amish Shah
4d2bb891a9 Fix doc gen 2016-09-04 11:39:40 +01:00