{"id":21290116,"url":"https://github.com/jumpn/utils-array","last_synced_at":"2025-07-11T14:32:11.625Z","repository":{"id":57103854,"uuid":"103874172","full_name":"jumpn/utils-array","owner":"jumpn","description":"Array utilities","archived":false,"fork":false,"pushed_at":"2017-10-01T02:27:40.000Z","size":389,"stargazers_count":0,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-02T16:52:32.427Z","etag":null,"topics":["array","functional-programming","immutability"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/jumpn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-18T00:51:53.000Z","updated_at":"2017-09-19T23:59:16.000Z","dependencies_parsed_at":"2022-08-20T21:10:12.469Z","dependency_job_id":null,"html_url":"https://github.com/jumpn/utils-array","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/jumpn/utils-array","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumpn%2Futils-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumpn%2Futils-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumpn%2Futils-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumpn%2Futils-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jumpn","download_url":"https://codeload.github.com/jumpn/utils-array/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumpn%2Futils-array/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264833280,"owners_count":23670617,"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","functional-programming","immutability"],"created_at":"2024-11-21T12:44:55.792Z","updated_at":"2025-07-11T14:32:11.180Z","avatar_url":"https://github.com/jumpn.png","language":"JavaScript","readme":"# @jumpn/utils-array\n\n\u003e Array utilities (immutability, fp helpers)\n\u003e\n\u003e **NOTE**: All the functions described in [API](#API) are curried\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\u003c!-- END doctoc --\u003e\n\n- [Installation](#installation)\n  - [Using npm](#using-npm)\n  - [Using yarn](#using-yarn)\n- [API](#api)\n  - [append](#append)\n  - [convertIfNot](#convertifnot)\n  - [cycleNext](#cyclenext)\n  - [fromObject](#fromobject)\n  - [insert](#insert)\n  - [isKey](#iskey)\n  - [isLastIndex](#islastindex)\n  - [isPossibleFromObject](#ispossiblefromobject)\n  - [prepend](#prepend)\n  - [reduceIf](#reduceif)\n  - [reduceWhile](#reducewhile)\n  - [remove](#remove)\n  - [repeat](#repeat)\n  - [replace](#replace)\n  - [resolveIndex](#resolveindex)\n- [License](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Installation\n\n### Using [npm](https://docs.npmjs.com/cli/npm)\n\n    $ npm install --save @jumpn/utils-array\n\n### Using [yarn](https://yarnpkg.com)\n\n    $ yarn add @jumpn/utils-array\n\n## API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### append\n\nReturns a new Array with elements appended to the one given.\n\n**Parameters**\n\n-   `elements` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\nReturns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\n### convertIfNot\n\nReturns input if it is an Array or returns a new Array with input inside if\nit is not.\n\n**Parameters**\n\n-   `input` **Input** \n\nReturns **(Input | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;Input\u003e)** \n\n### cycleNext\n\nReturns 0 if current index is the last one, or returns next if it is not.\n\n**Parameters**\n\n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;any\u003e** \n-   `currentIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n\nReturns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n\n### fromObject\n\nCreates a new array using the given object\nIf all of its entries are array keys.\n\n(it could also have a property length with its size)\n\n**Parameters**\n\n-   `object` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** \n\nReturns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;any\u003e** \n\n### insert\n\nReturns a new Array with the result of having inserted the given elements at\nthe specified index.\n\n**Parameters**\n\n-   `index` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n-   `elements` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\nReturns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\n### isKey\n\nReturns true if the given string is an Array key or false otherwise.\n\n**Parameters**\n\n-   `string` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** \n\nReturns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \n\n### isLastIndex\n\nReturns true if given index is the last one or false otherwise.\n\n**Parameters**\n\n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;any\u003e** \n-   `index` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n\nReturns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \n\n### isPossibleFromObject\n\nReturns true if an Array can be created from the given Object, or in other\nwords, if it has or not a length property, and the rest of its keys are Array\nones.\n\n**Parameters**\n\n-   `$0` **any** \n    -   `$0.length`  \n    -   `$0.rest` **...any** \n\nReturns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \n\n### prepend\n\nReturns a new Array with elements prepended to the one given.\n\n**Parameters**\n\n-   `elements` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\nReturns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\n### reduceIf\n\nReduce the given array applying reduce function only to elements filtered.\n\n**Parameters**\n\n-   `filter` **Filter\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element), Result\u003e** \n-   `reduce` **Reduce\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element), Result\u003e** \n-   `resultInitial` **$Subtype\u0026lt;Result\u003e** \n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;$Subtype\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e\u003e** \n\nReturns **Result** \n\n### reduceWhile\n\nReduce the given array applying reduce function while shouldProceed function\nreturns true.\n\n**Parameters**\n\n-   `shouldProceed` **ShouldProceed\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element), Result\u003e** \n-   `reduce` **Reduce\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element), Result\u003e** \n-   `resultInitial` **Result** \n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\nReturns **Result** \n\n### remove\n\nReturns a new Array with the result of having removed the specified amount\n(count) of elements at the given index.\n\n**Parameters**\n\n-   `index` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n-   `count` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\nReturns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\n### repeat\n\nReturns a new Array with the given size (count) filled with the specified\nelement.\n\n**Parameters**\n\n-   `count` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n-   `element` **[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)** \n\nReturns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\n### replace\n\nReturns a new Array with the result of having replaced the elements at the\ngiven index with the ones specified.\n\n**Parameters**\n\n-   `index` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n-   `elements` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\nReturns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;[Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)\u003e** \n\n### resolveIndex\n\nReturns an absolute index from a relative one.\n\nRelative indexes differ from absolute ones in that they can be negative and\nin those cases it would be as simple as substracting them from the length of\nthe array from where they belong to obtain their absolute counterparts.\n\n**Parameters**\n\n-   `array` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)\u0026lt;any\u003e** \n-   `relativeIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n\nReturns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** \n\n## License\n\n[MIT](LICENSE.txt) :copyright: **Jumpn Limited** / Mauro Titimoli (mauro@jumpn.com)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumpn%2Futils-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjumpn%2Futils-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumpn%2Futils-array/lists"}