{"id":23170266,"url":"https://github.com/mrchief/array.partial","last_synced_at":"2025-04-04T23:15:14.232Z","repository":{"id":57184189,"uuid":"126658992","full_name":"mrchief/array.partial","owner":"mrchief","description":"When you want array.some but not array.every","archived":false,"fork":false,"pushed_at":"2019-06-27T02:57:33.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-10T15:06:25.325Z","etag":null,"topics":["array","every","filter","partial","some"],"latest_commit_sha":null,"homepage":"","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/mrchief.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-25T02:50:07.000Z","updated_at":"2023-02-20T08:16:45.000Z","dependencies_parsed_at":"2022-09-14T09:00:30.706Z","dependency_job_id":null,"html_url":"https://github.com/mrchief/array.partial","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/mrchief%2Farray.partial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrchief%2Farray.partial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrchief%2Farray.partial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrchief%2Farray.partial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrchief","download_url":"https://codeload.github.com/mrchief/array.partial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247261603,"owners_count":20910108,"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","every","filter","partial","some"],"created_at":"2024-12-18T03:26:28.380Z","updated_at":"2025-04-04T23:15:14.195Z","avatar_url":"https://github.com/mrchief.png","language":"JavaScript","readme":"# array.partial [![Build Status](https://travis-ci.org/mrchief/array.partial.svg?branch=master)](https://travis-ci.org/mrchief/array.partial)\n\n[![npm](https://img.shields.io/npm/v/array.partial.svg)](https://www.npmjs.com/package/array.partial)\n[![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/array.partial.svg)](https://bundlephobia.com/result?p=array.partial)\n\n---\n\n\u003e When you want array.some but not array.every\n\nUseful when you need to determine \"partially\" selected states - like partially selecting tree nodes when some but not all child nodes are checked.\n\nIn fact, the idea originated while building a feature for my own [react-dropdown-tree-select](https://github.com/dowjones/react-dropdown-tree-select) component.\n\n## Why\n\n[array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some) returns true when _at least one_ element matches. [array.every](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) returns true when _all_ elements match. `array.some` will also return true when `array.every` returns true.\n\n`array.partial` is something in between. It returns `true` **only, and only when** _some_ (but not all) elements match. If all elements match, then it'll return `false`.\n\nThis can also be achieved with `array.some \u0026\u0026 !array.every` if you don't mind iterating over the array twice. This module does it with one iteration over the array.\n\n## Install\n\n```\nnpm install array.partial\n```\n\n## Usage\n\n```\nconst partial = require('array.partial')\npartial(array, predicate)\n```\n\n## API\n\n### partial(array, predicate)\n\nReturn true if and only if some elements pass the check, otherwise false.\n\n#### array\n\nType: `Array` - Input array\n\n#### predicate\n\nType: `Function` - A predicate, to test each element of the array. This is called with the following arguments:\n\n`element` - The current element being processed in the array\n\n`index` (Optional) - The index of the current element being processed in the array.\n\n`array` (Optional) - The array filter was called upon.\n\n## Examples\n\n```\nconst partial = require('array.partial')\n\nconst myArr = [{id: 'a1', checked: true}, {id: 'a2', checked: false}]\npartial(myArr, x =\u003e x.checked)  // -\u003e returns true\n\n// ...\n\nconst myArr = [{id: 'a1', checked: true}, {id: 'a2', checked: true}]\npartial(myArr, x =\u003e x.checked)  // -\u003e returns false\n\n// ...\n\nconst myArr = [{id: 'a1', checked: false}, {id: 'a2', checked: false}]\npartial(myArr, x =\u003e x.checked)  // -\u003e returns false\n```\n\n## License\n\nMIT © [Hrusikesh Panda](https://about.me/hkpanda)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrchief%2Farray.partial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrchief%2Farray.partial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrchief%2Farray.partial/lists"}