{"id":13683744,"url":"https://github.com/Bin-Huang/prray","last_synced_at":"2025-04-30T13:31:51.562Z","repository":{"id":34985313,"uuid":"142326172","full_name":"Bin-Huang/prray","owner":"Bin-Huang","description":"\"Promisified\" Array, it compatible with the original Array but comes with async versions of native Array methods","archived":false,"fork":false,"pushed_at":"2024-08-26T03:16:45.000Z","size":640,"stargazers_count":126,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T17:55:58.931Z","etag":null,"topics":["array","async","bluebird","filterasync","javascript","mapasync","nodejs","promise","reduceasync"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bin-Huang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-25T16:28:28.000Z","updated_at":"2025-02-24T09:36:58.000Z","dependencies_parsed_at":"2024-10-25T17:11:44.829Z","dependency_job_id":"4610cecc-6af6-4aea-8d11-039d92c5984a","html_url":"https://github.com/Bin-Huang/prray","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bin-Huang%2Fprray","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bin-Huang%2Fprray/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bin-Huang%2Fprray/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bin-Huang%2Fprray/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bin-Huang","download_url":"https://codeload.github.com/Bin-Huang/prray/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251712897,"owners_count":21631462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","async","bluebird","filterasync","javascript","mapasync","nodejs","promise","reduceasync"],"created_at":"2024-08-02T13:02:28.360Z","updated_at":"2025-04-30T13:31:51.179Z","avatar_url":"https://github.com/Bin-Huang.png","language":"TypeScript","funding_links":["https://buymeacoffee.com/benn"],"categories":["TypeScript"],"sub_categories":[],"readme":"[![Travis](https://img.shields.io/travis/Bin-Huang/prray)](https://travis-ci.com/Bin-Huang/prray)\n[![Package version](https://img.shields.io/npm/v/prray)](https://www.npmjs.com/package/prray)\n[![Coverage Status](https://coveralls.io/repos/github/Bin-Huang/prray/badge.svg?branch=master)](https://coveralls.io/github/Bin-Huang/prray?branch=master)\n[![Install size](https://packagephobia.now.sh/badge?p=prray)](https://packagephobia.now.sh/result?p=prray)\n![License](https://img.shields.io/npm/l/prray)\n\n\u003c!-- [![Download](https://img.shields.io/npm/dm/prray)](https://www.npmjs.com/package/prray) --\u003e\n\nPrray -- \"Promisified\" Array, it compatible with the original Array but comes with async versions of native Array methods, such as mapAsync, filterAsync, everyAsync...\n\n- [compatible with normal array](#compatibility-with-normal-array)\n- comes with async versions of native Array methods\n- supports **method chaining** with normal and async methods\n- supports concurrency limit\n- it works without any prototype pollution\n- [zero-dependency](https://github.com/Bin-Huang/prray/blob/master/package.json#L7), it can run on both browser and Node.js\n- [well-tested](https://github.com/Bin-Huang/prray/tree/master/test), well-documented \n\n```javascript\nimport Prray from 'prray'\n\n// 1) create\nconst urls = Prray.from(['www.google.com', 'npmjs.org'])\n\n\n// 2) async method\nlet responses = await urls.mapAsync(fetch)\n\n\n// 3) method chaining with both normal and async methods\nawait urls\n  .concat(['github.com', 'wikipedia.org'])\n  .mapAsync(request)\n  .filter(isValidHtml)\n  .forEachAsync(saveToDB)\n\n\n// 4) concurrency limit\nresponses = await urls.mapAsync(fetch, { concurrency: 10 })\n```\n\n\u003e Prray aims to replace the original Array in some cases for convenience 😜\n\n- [Install](#install)\n- [Compatibility with normal Array](#compatibility-with-normal-array)\n- [How it work?](#how-it-work)\n- [Distinguish between prray and normal array](#distinguish-between-prray-and-normal-array)\n- [Methods](#methods)\n  - [Class Prray](#class-prray)\n  - [Static methods of Class Prray](#static-methods-of-class-prray)\n  - [Specific methods of Prray instance](#specific-methods-of-prray-instance)\n  - [Other methods of Prray instance (compatible with Array)](#other-methods-of-prray-instance-compatible-with-array)\n- [Why not `bluebird`](#why-not-bluebird)\n- [License](#license)\n\n## Install\n\nnpm\n\n```\nnpm install prray --save\n```\n\nyarn\n\n```\nyarn add prray\n```\n\n## Compatibility with normal Array\n\nPrray is compatible with normal array. That means you can safely replace normal Array with Prray. And there are [a lots of unit tests](https://github.com/Bin-Huang/prray/tree/master/test) for prray to test compatibility with normal array.\n\n```javascript\nimport Prray from 'prray'\n\nconst arr = [1, 2, 3]\nconst prr = Prray.from(arr)\n\n\nprr[0] // 1\nprr[prr.length - 1] // 3\nprr.length // 3\n\n\nprr instanceof Array // true\nArray.isArray(prr) // true\n\n\nJSON.stringify(prr) // \"[1, 2, 3]\"\n\n\nfor (const v of prr) {\n  console.log(v)\n}\n// 1\n// 2\n// 3\n\n\n[ ...prr ] // [1,2,3]\n\n\nconst iterator = prr[Symbol.iterator]()\niterator.next().value // 1\niterator.next().value // 2\niterator.next().value // 3\niterator.next().done // true\n\n\n// In typescript, type Prray is compatible with type Array\nfunction func(arr: number[]) {\n  return arr\n}\nfunc(new Prray(1, 2, 3))\n```\n\n## How it work?\n\nClass Prray inherits the original class Array and adds or overrides methods based on it. It works without any prototype pollution and global pollution.\n\n```javascript\nconst prr = Prray.from([1, 2, 3])\nconsole.log(prr.mapAsync) // [Function]\n\nconst arr = [1, 2, 3]\nconsole.log(arr.mapAsync) // [undefined]\n```\n\n## Distinguish between prray and normal array\n\n```javascript\nconst prr = new Prray(1, 2, 3)\nconst arr = new Array(1, 2, 3)\n\nPrray.isPrray(prr) // true\nPrray.isPrray(arr) // false\n\nprr instanceof Prray // true\narr instanceof Prray // false\n```\n\n## Methods\n\n### Class Prray\n\nThe class `Prray`. You can think of it as class `Array`.\n\n```javascript\nimport Prray from 'prray'\n\nconst p1 = new Prray()\nconst p2 = new Prray('a', 'b')\nconst p3 = Prray.from([1, 2, 3, 4])\n\nconsole.log(p2[0]) // 'a'\n```\n\n\u003e **[NOTE]: Instead `new Prray()`, use `Prray.from` or `Prray.of` if you want to create a new prray instance with items**. Because the class Prray is so compatible with class Array, some \"weird\" behaviors that exists in `new Array()` can also occurs: when you calling `new Array(1)`, you get `[ \u003c1 empty item\u003e ]` instead of expected `[ 1 ]`.\n\n### Static methods of Class Prray\n\n- [Prray.from(arrayLike)](#prrayfromarraylike)\n- [Prray.of(...args)](#prrayofargs)\n- [Prray.isPrray(obj)](#prrayisprrayobj)\n- [Prray.delay(ms)](#prraydelayms)\n\n#### Prray.from(arrayLike)\n\n_Compatible with [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) but returns a Prray instance._\n\nThe Prray.from() method creates a new, shallow-copied Prray instance from an array-like or iterable object.\n\n```javascript\nconst prr = Prray.from([1, 2, 3, 4])\n```\n\n#### Prray.of(...args)\n\n_Compatible with [`Array.of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of) but returns a Prray instance._\n\nThe Prray.of() method creates a new Prray instance from a variable number of arguments, regardless of number or type of the arguments.\n\n```javascript\nconst prr = Prray.of(1, 2, 3, 4)\n```\n\n#### Prray.isPrray(obj)\n\nThe Prray.isArray() method determines whether the passed value is a Prray instance.\n\n```javascript\nPrray.isPrray([1, 2, 3]) // false\nPrray.isPrray(new Prray(1, 2, 3)) // true\n```\n\n#### Prray.delay(ms)\n\nThe Prray.delay() method returns a promise (`PrrayPromise` exactly) that will be resolved after given ms milliseconds.\n\n```javascript\nawait Prray.delay(1000) // resolve after 1 second\n\nconst prr = Prray.from([1,2,3])\nawait prr\n    .mapAsync(action1)\n    .delay(500)    // delay 500ms between two iterations\n    .forEach(action2)\n```\n\n### Specific methods of Prray instance\n\n- [Prray.prototype.toArray()](#prrayprototypetoarray)\n- [Prray.prototype.delay()](#prrayprototypedelayms)\n- [Prray.prototype.mapAsync(func, options)](#prrayprototypemapasyncfunc-options)\n- [Prray.prototype.filterAsync(func, options)](#prrayprototypefilterasyncfunc-options)\n- [Prray.prototype.reduceAsync(func, initialValue)](#prrayprototypereduceasyncfunc-initialvalue)\n- [Prray.prototype.reduceRightAsync(func, initialValue)](#prrayprototypereducerightasyncfunc-initialvalue)\n- [Prray.prototype.findAsync(func)](#prrayprototypefindasyncfunc)\n- [Prray.prototype.findIndexAsync(func)](#prrayprototypefindindexasyncfunc)\n- [Prray.prototype.everyAsync(func, options)](#prrayprototypeeveryasyncfunc-options)\n- [Prray.prototype.someAsync(func, options)](#prrayprototypesomeasyncfunc-options)\n- [Prray.prototype.sortAsync(func)](#prrayprototypesortasyncfunc)\n- [Prray.prototype.forEachAsync(func, options)](#prrayprototypeforeachasyncfunc-options)\n\n#### Prray.prototype.toArray()\n\nThe toArray() method returns a new normal array with every element in the prray.\n\n```javascript\nconst prr = new Prray(1, 2, 3)\n\nprr.toArray() // [1,2,3]\n```\n\n#### Prray.prototype.delay(ms)\n\nThe delay() method returns a promise (`PrrayPromise` exactly) that will be resolved with current prray instance after given ms milliseconds.\n\n```javascript\nconst emails = Prray.from(emailArray)\nawait emails\n    .mapAsync(registerReceiver)\n    .delay(1000)\n    .forEachAsync(send)\n```\n\n#### Prray.prototype.mapAsync(func, options)\n\n_Think of it as an async version of method `map`_\n\nThe mapAsync() method returns a promise (`PrrayPromise` exactly) that resolved with a new prray with the resolved results of calling a provided async function on every element in the calling prray, or rejected immediately if any of the promises reject.\n\nThe provided async function is called on every element concurrently. You may optionally specify a concurrency limit.\n\n- `func(currentValue, index, prray)`\n- options\n  - `concurrency` Number of concurrently pending promises returned by provided function. Default: `Infinity`\n\n```javascript\nconst urls = Prray.from(urlArray)\n\nconst jsons = await urls.mapAsync(fetch).mapAsync(res =\u003e res.json())\n\nawait jsons.mapAsync(insertToDB, { concurrency: 2 })\n```\n\n#### Prray.prototype.filterAsync(func, options)\n\n_Think of it as an async version of method `filter`_\n\nThe filterAsync() method returns a promise (`PrrayPromise` exactly) that resolved with a new prray with all elements that pass the test implemented by the provided async function, or rejected immediately if any of the promises reject.\n\nThe provided async function is called on every element concurrently. You may optionally specify a concurrency limit.\n\n- `func(currentValue, index, prray)`\n- options\n  - `concurrency` Number of concurrently pending promises returned by provided function. Default: `Infinity`\n\n```javascript\nconst files = Prray.from(fileArray)\n\nawait files.filterAsync(isExisted).mapAsync(removeFile)\n\nawait files.filterAsync(isExisted, { concurrency: 2 })\n```\n\n#### Prray.prototype.reduceAsync(func, initialValue)\n\n_Think of it as an async version of method `reduce`_\n\nThe reduceAsync() method executes a async reducer function (that you provide) on each element of the prray, resulting in a single output value resolved by a promise (`PrrayPromise` exactly).\n\n```javascript\nconst productIds = Prray.from(idArray)\n\nconst total = await productIds.reduceAsync(async (total, id) =\u003e {\n  const price = await getPrice(id)\n  return total + price\n}, 0)\n```\n\n#### Prray.prototype.reduceRightAsync(func, initialValue)\n\n_Think of it as an async version of method `reduceRight`_\n\nThe reduceRightAsync() method applies an async function against an accumulator and each value of the prray (from right-to-left) to reduce it to a single value.\n\n```javascript\nconst productIds = Prray.from(idArray)\n\nconst total = await productIds.reduceRightAsync(async (total, id) =\u003e {\n  const price = await getPrice(id)\n  return total + price\n}, 0)\n```\n\n#### Prray.prototype.findAsync(func)\n\n_Think of it as an async version of method `find`_\n\nThe findAsync() method returns a promise (`PrrayPromise` exactly) resolved with the first element in the prray that satisfies the provided async testing function.\n\n```javascript\nconst workers = Prray.from(workerArray)\n\nconst unhealthy = await workers.findAsync(checkHealth)\n```\n\n#### Prray.prototype.findIndexAsync(func)\n\n_Think of it as an async version of method `findIndex`_\n\nThe findIndexAsync() method returns a promise (`PrrayPromise` exactly) resolved with the index of the first element in the prray that satisfies the provided async testing function. Otherwise, it returns promise resolved with -1, indicating that no element passed the test.\n\n```javascript\nconst workers = Prray.from(workerArray)\nconst ix = await workers.findIndexAsync(checkHealth)\nconst unhealthy = workers[ix]\n```\n\n#### Prray.prototype.everyAsync(func, options)\n\n_Think of it as an async version of method `every`_\n\nThe everyAsync() method tests whether all elements in the prray pass the test implemented by the provided async function. It returns a promise (`PrrayPromise` exactly) that resolved with a Boolean value, or rejected immediately if any of the promises reject.\n\nThe provided async function is called on every element concurrently. You may optionally specify a concurrency limit.\n\n- `func(currentValue, index, prray)`\n- options\n  - `concurrency` Number of concurrently pending promises returned by provided function. Default: `Infinity`\n\n```javascript\nconst filenames = Prray.from(fileNameArray)\n\nconst isAllFileExisted = await filenames.everyAsync(isExisted)\nif (isAllFileExisted) {\n  // do some things\n}\n```\n\n#### Prray.prototype.someAsync(func, options)\n\n_Think of it as an async version of method `some`_\n\nThe some() method tests whether at least one element in the prray passes the test implemented by the provided async function. It returns a promise (`PrrayPromise` exactly) that resolved with Boolean value, or rejected immediately if any of the promises reject.\n\nThe provided async function is called on every element concurrently. You may optionally specify a concurrency limit.\n\n- `func(currentValue, index, prray)`\n- options\n  - `concurrency` Number of concurrently pending promises returned by provided function. Default: `Infinity`\n\n```javascript\nconst filenames = Prray.from(fileNameArray)\n\nconst hasExistedFile = await filenames.someAsync(isExisted)\nif (hasExistedFile) {\n  // do some things\n}\n```\n\n#### Prray.prototype.sortAsync(func)\n\n_Think of it as an async version of method `sort`_\n\nThe sortAsync() method sorts the elements of a prray in place and returns a promise (`PrrayPromise` exactly) resolved with the sorted prray. The provided function can be an async function that returns a promise resolved with a number.\n\n```javascript\nconst students = Prray.from(idArray)\n\nconst rank = await students.sortAsync((a, b) =\u003e {\n  const scoreA = await getScore(a)\n  const scoreB = await getScore(b)\n  return scoreA - scoreB\n})\n```\n\n#### Prray.prototype.forEachAsync(func, options)\n\n_Think of it as an async version of method `forEach`_\n\nThe forEachAsync() method executes a provided async function once for each prray element concurrently. It returns a promise (`PrrayPromise` exactly) that resolved after all iteration promises resolved, or rejected immediately if any of the promises reject.\n\nThe provided async function is called on every element concurrently. You may optionally specify a concurrency limit.\n\n- `func(currentValue, index, prray)`\n- options\n  - `concurrency` Number of concurrently pending promises returned by provided function. Default: `Infinity`\n\n```javascript\nconst emails = Prray.from(emailArray)\nawait emails.forEachAsync(sendAsync)\n\n// or\nawait emails.forEachAsync(sendAsync, { concurrency: 20 })\n```\n\n### Other methods of Prray instance (compatible with Array)\n\n- [Prray.prototype.map(func)](#prrayprototypemapfunc)\n- [Prray.prototype.filter(func)](#prrayprototypefilterfunc)\n- [Prray.prototype.reduce(func, initialValue)](#prrayprototypereducefunc-initialvalue)\n- [Prray.prototype.reduceRight(func, initialValue)](#prrayprototypereducerightfunc-initialvalue)\n- [Prray.prototype.find(func)](#prrayprototypefindfunc)\n- [Prray.prototype.findIndex(func)](#prrayprototypefindindexfunc)\n- [Prray.prototype.every(func)](#prrayprototypeeveryfunc)\n- [Prray.prototype.some(func)](#prrayprototypesomefunc)\n- [Prray.prototype.sort(func)](#prrayprototypesortfunc)\n- [Prray.prototype.forEach(func)](#prrayprototypeforeachfunc)\n- [Prray.prototype.slice(start, end)](#prrayprototypeslicestart-end)\n- [Prray.prototype.includes(value)](#prrayprototypeincludesvalue)\n- [Prray.prototype.indexOf(value)](#prrayprototypeindexofvalue)\n- [Prray.prototype.lastIndexOf(value)](#prrayprototypelastindexofvalue)\n- [Prray.prototype.join(separator)](#prrayprototypejoinseparator)\n- [Prray.prototype.keys()](#prrayprototypekeys)\n- [Prray.prototype.values()](#prrayprototypevalues)\n- [Prray.prototype.entries()](#prrayprototypeentries)\n- [Prray.prototype.fill(value, start, end)](#prrayprototypefillvalue-start-end)\n- [Prray.prototype.concat(arr)](#prrayprototypeconcatarr)\n- [Prray.prototype.copyWithin(target, star, end)](#prrayprototypecopywithintarget-star-end)\n- [Prray.prototype.pop()](#prrayprototypepop)\n- [Prray.prototype.push(...elements)](#prrayprototypepushelements)\n- [Prray.prototype.reverse()](#prrayprototypereverse)\n- [Prray.prototype.shift()](#prrayprototypeshift)\n- [Prray.prototype.unshift(...elements)](#prrayprototypeunshiftelements)\n- [Prray.prototype.splice(start, deleteCount, ...items)](#prrayprototypesplicestart-deletecount-items)\n- [Prray.prototype.toString()](#prrayprototypetostring)\n- [Prray.prototype.toLocaleString()](#prrayprototypetolocalestring)\n\n#### Prray.prototype.map(func)\n\n_Compatible with [Array.prototype.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)_ but returns a Prray instance.\n\nThe map() method creates a new prray with the results of calling a provided function on every element in the calling prray.\n\n#### Prray.prototype.filter(func)\n\n_Compatible with [Array.prototype.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)_ but returns a Prray instance.\n\nThe filter() method creates a new prray with all elements that pass the test implemented by the provided function.\n\n#### Prray.prototype.reduce(func, initialValue)\n\n_Compatible with [Array.prototype.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce)_.\n\nThe reduce() method executes a reducer function (that you provide) on each element of the prray, resulting in a single output value.\n\n#### Prray.prototype.reduceRight(func, initialValue)\n\n_Compatible with [Array.prototype.reduceRight](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ReduceRight)_\n\nThe reduceRight() method applies a function against an accumulator and each value of the prray (from right-to-left) to reduce it to a single value.\n\n#### Prray.prototype.find(func)\n\n_Compatible with [Array.prototype.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)_\n\nThe find() method returns the value of the first element in the prray that satisfies the provided testing function.\n\n#### Prray.prototype.findIndex(func)\n\n_Compatible with [Array.prototype.findIndex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex)_\n\nThe findIndex() method returns the index of the first element in the prray that satisfies the provided testing function. Otherwise, it returns -1, indicating that no element passed the test.\n\n#### Prray.prototype.every(func)\n\n_Compatible with [Array.prototype.every](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)_\n\nThe every() method tests whether all elements in the prray pass the test implemented by the provided function. It returns a Boolean value.\n\n#### Prray.prototype.some(func)\n\n_Compatible with [Array.prototype.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)_\n\nThe some() method tests whether at least one element in the prray passes the test implemented by the provided function. It returns a Boolean value.\n\n#### Prray.prototype.sort(func)\n\n_Compatible with [Array.prototype.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)_\n\nThe sort() method sorts the elements of a prray in place and returns the sorted prray.\n\n#### Prray.prototype.forEach(func)\n\n_Compatible with [Array.prototype.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)_\n\nThe forEach() method executes a provided function once for each prray element.\n\n#### Prray.prototype.slice(start, end)\n\n_Compatible with [Array.prototype.slice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)_ but returns a Prray instance\n\nThe slice() method returns a shallow copy of a portion of a prray into a new prray object selected from begin to end (end not included) where begin and end represent the index of items in that prray. The original prray will not be modified.\n\n#### Prray.prototype.includes(value)\n\n_Compatible with [Array.prototype.includes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)_\n\nThe includes() method determines whether a prray includes a certain value among its entries, returning true or false as appropriate.\n\n#### Prray.prototype.indexOf(value)\n\n_Compatible with [Array.prototype.indexOf](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)_\n\nThe indexOf() method returns the first index at which a given element can be found in the prray, or -1 if it is not present.\n\n#### Prray.prototype.lastIndexOf(value)\n\n_Compatible with [Array.prototype.lastIndexOf](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf)_\n\nThe lastIndexOf() method returns the last index at which a given element can be found in the prray, or -1 if it is not present. The prray is searched backwards, starting at fromIndex.\n\n#### Prray.prototype.join(separator)\n\n_Compatible with [Array.prototype.join](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)_\n\nThe join() method creates and returns a new string by concatenating all of the elements in a prray (or an array-like object), separated by commas or a specified separator string. If the prray has only one item, then that item will be returned without using the separator.\n\n#### Prray.prototype.keys()\n\n_Compatible with [Array.prototype.keys](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys)_\n\nThe keys() method returns a new Array Iterator object that contains the keys for each index in the prray.\n\n#### Prray.prototype.values()\n\n_Compatible with [Array.prototype.values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values)_\n\nThe values() method returns a new Array Iterator object that contains the values for each index in the prray.\n\n#### Prray.prototype.entries()\n\n_Compatible with [Array.prototype.entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries)_\n\nThe entries() method returns a new Array Iterator object that contains the key/value pairs for each index in the prray.\n\n#### Prray.prototype.fill(value, start, end)\n\n_Compatible with [Array.prototype.fill](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)_\n\nThe fill() method fills (modifies) all the elements of a prray from a start index (default zero) to an end index (default array length) with a static value. It returns the modified prray.\n\n#### Prray.prototype.concat(arr)\n\n_Compatible with [Array.prototype.concat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)_ but returns a Prray instance\n\nThe concat() method is used to merge two or more prrays and arrays. This method does not change the existing prrays, but instead returns a new prray.\n\n#### Prray.prototype.copyWithin(target, star, end)\n\n_Compatible with [Array.prototype.copyWithin](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin)_\n\nThe copyWithin() method shallow copies part of a prray to another location in the same prray and returns it without modifying its length.\n\n#### Prray.prototype.pop()\n\n_Compatible with [Array.prototype.pop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop)_\n\nThe pop() method removes the last element from a prray and returns that element. This method changes the length of the prray.\n\n#### Prray.prototype.push(...elements)\n\n_Compatible with [Array.prototype.push](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push)_\n\nThe push() method adds one or more elements to the end of a prray and returns the new length of the prray.\n\n#### Prray.prototype.reverse()\n\n_Compatible with [Array.prototype.reverse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)_\n\nThe reverse() method reverses a prray in place. The first prray element becomes the last, and the last prray element becomes the first.\n\n#### Prray.prototype.shift()\n\n_Compatible with [Array.prototype.shift](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)_\n\nThe shift() method removes the first element from a prray and returns that removed element. This method changes the length of the prray.\n\n#### Prray.prototype.unshift(...elements)\n\n_Compatible with [Array.prototype.unshift](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)_\n\nThe unshift() method adds one or more elements to the beginning of a prray and returns the new length of the prray.\n\n#### Prray.prototype.splice(start, deleteCount, ...items)\n\n_Compatible with [Array.prototype.splice](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice)_ but returns a Prray instance.\n\nThe splice() method changes the contents of a prray by removing or replacing existing elements and/or adding new elements in place.\n\n#### Prray.prototype.toString()\n\n_Compatible with [Array.prototype.toString](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString)_\n\nThe toString() method returns a string representing the specified prray and its elements.\n\n#### Prray.prototype.toLocaleString()\n\n_Compatible with [Array.prototype.toLocaleString](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString)_\n\nThe toLocaleString() method returns a string representing the elements of the prray. The elements are converted to Strings using their toLocaleString methods and these Strings are separated by a locale-specific String (such as a comma “,”).\n\n## Why not `bluebird`\n\nBluebird and prray have different concerns, so it may not be suitable for comparison. If you must compare, can also try:\n\n1. Prray focuses on arrays, Bluebird focuses on promises\n2. Bluebird has some methods such as `map`, but prray has more: `findAsync`, `everyAsync`, etc\n3. Prray supports async method chaining, but for bluebird, you have to: `Bluebird.map(await Bluebird.map(arr,func1), func2)`\n4. Prray is based on native promise implementation, and bluebird provides a good third-party promise implementation\n\n## Sponsoring\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://buymeacoffee.com/benn)\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBin-Huang%2Fprray","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBin-Huang%2Fprray","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBin-Huang%2Fprray/lists"}