array-reject
⚠️ This module extend the global Array.prototype.
Array.prototype.reject(callback)
return new array which removed value matched condition.
This is the opposite of Array.prototype.filter
!
install
$ npm install array-reject
usage
;
example
const arr = 1 2 3 4 5; { return { return x > n; };} arr;// => [1, 2, 3]arr;// => [4, 5]
const cities = 'Tokyo' 'Kyoto' 'Osaka' 'NewYork' 'Helsinki' 'Tampere' 'Espoo'; cities;// => ['Helsinki', 'Tampere']
const idols = name: 'Hoshimiya Ichigo' type: 'cute' name: 'Kiriya Aoi' type: 'cool' name: 'Shibuki Ran' type: 'sexy' name: 'Arisugawa Otome' type: 'pop' name: 'Todo Yurika' type: 'cool' name: 'Kamiya Shion' type: 'cool' name: 'Ichinose Kaede' type: 'pop' name: 'Minowa Hikari' type: 'sexy' name: 'Kanzaki Mizuki' type: 'sexy' name: 'Natsuki Mikuru' type: 'pop' name: 'Kitaoji Sakura' type: 'cute' name: 'Ozora Akari' type: 'cute' name: 'Hattori Yu' type: 'cool' name: 'Hikami Sumire' type: 'cool' name: 'Shinjo Hinaki' type: 'pop' name: 'Kurebayashi Juri' type: 'sexy' name: 'Kurosawa Rin' type: 'cool' name: 'Amahane Madoka' type: 'cute' ; { return { return idoltype === type };} const notCoolIdols = idols;/* [ {name: "Hoshimiya Ichigo", type: "cute"}, {name: "Shibuki Ran", type: "sexy"}, {name: "Arisugawa Otome", type: "pop"}, {name: "Ichinose Kaede", type: "pop"}, {name: "Minowa Hikari", type: "sexy"}, {name: "Kanzaki Mizuki", type: "sexy"}, {name: "Natsuki Mikuru", type: "pop"}, {name: "Kitaoji Sakura", type: "cute"}, {name: "Ozora Akari", type: "cute"}, {name: "Shinjo Hinaki", type: "pop"}, {name: "Kurebayashi Juri", type: "sexy"}, {name: "Amahane Madoka", type: "cute"},] */
Array.reject
?
When already has Own Old Array.prototype.reject
be renamed to Array.prototype.__reject
.
And run old reject function before this Array.prototype.reject
.
👌
;;
😇
// This override `array-reject` Arrayprototype { // ...} ;
example
// my-array-reject.jsArrayprototype { if typeofindex !== 'number' return this; const res = ; forlet i = 0 l = thislength; i < l; i += 1 if i !== index res; return res;};
;; const arr = 1 2 3 4 5 6 7 8 9 10; { return { return x > n; };} // run my Array.rejectarr;// => [2, 3, 4, 5, 6, 7, 8, 9, 10] arr;// => [1, 2, 3] // run array-reject after my Array.rejectarr;// => [2, 3] // array-reject use last argument as a callbackarr;// => [2, 3]
test
$ npm run test