{"id":21883797,"url":"https://github.com/vovanr/toggle-in-array","last_synced_at":"2025-04-15T06:28:22.946Z","repository":{"id":57377667,"uuid":"117557814","full_name":"VovanR/toggle-in-array","owner":"VovanR","description":"Add or remove item from array","archived":false,"fork":false,"pushed_at":"2022-12-16T19:35:46.000Z","size":162,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T17:04:08.050Z","etag":null,"topics":["array-manipulations","utility"],"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/VovanR.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-01-15T14:48:26.000Z","updated_at":"2023-01-23T15:31:16.000Z","dependencies_parsed_at":"2023-01-29T15:45:15.877Z","dependency_job_id":null,"html_url":"https://github.com/VovanR/toggle-in-array","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VovanR%2Ftoggle-in-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VovanR%2Ftoggle-in-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VovanR%2Ftoggle-in-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VovanR%2Ftoggle-in-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VovanR","download_url":"https://codeload.github.com/VovanR/toggle-in-array/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249019941,"owners_count":21199457,"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-manipulations","utility"],"created_at":"2024-11-28T09:46:52.674Z","updated_at":"2025-04-15T06:28:22.927Z","avatar_url":"https://github.com/VovanR.png","language":"JavaScript","readme":"# toggle-in-array\n\n[![Commitizen friendly][commitizen-image]][commitizen-url]\n[![XO code style][codestyle-image]][codestyle-url]\n\n[![NPM version][npm-image]][npm-url]\n[![Build Status][build-image]][build-url]\n[![Coveralls Status][coveralls-image]][coveralls-url]\n\n\u003e Add or remove item from array\n\n## Install\n\n```shell\nnpm install --save toggle-in-array\n```\n\n## Usage\n\n```js\nvar toggleInArray = require('toggle-in-array');\n\ntoggleInArray([1, 2, 3], 2);\n//=\u003e [1, 3]\n\ntoggleInArray([1, 2, 3], 4);\n//=\u003e [1, 2, 3, 4]\n\ntoggleInArray(\n  [{v: 1}, {v: 2}, {v: 3}],\n  {v: 2},\n  (a, b) =\u003e a.v === b.v\n);\n//=\u003e [{v: 1}, {v: 3}]\n```\n\n## API\n\n### `toggleInArray(array, value, [predicate])`\n\nReturns an `Array` with `value` if `array` is not includes this `value`\u003cbr\u003e\nReturns an `Array` without `value` if `array` is includes this `value`\n\n#### array\n*Required*\u003cbr\u003e\nType: `Array`\n\nArray with values needs to toggle\n\n#### value\n*Required*\u003cbr\u003e\nType: `*`\n\nValue to toggle in `array`\n\n#### predicate\nType: `Function`\u003cbr\u003e\nDefault: `(a, b) =\u003e a === b` *Strict equality comparison*\n\nFunction that compare each `array` item to equal `value`\n\n## License\nMIT © [Vladimir Rodkin](https://github.com/VovanR)\n\n[commitizen-url]: https://commitizen.github.io/cz-cli/\n[commitizen-image]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square\n\n[codestyle-url]: https://github.com/xojs/xo\n[codestyle-image]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg?style=flat-square\n\n[npm-url]: https://npmjs.org/package/toggle-in-array\n[npm-image]: https://img.shields.io/npm/v/toggle-in-array.svg?style=flat-square\n\n[build-url]: https://github.com/VovanR/toggle-in-array/actions/workflows/test-workflow.yml\n[build-image]: https://img.shields.io/github/actions/workflow/status/vovanr/toggle-in-array/test-workflow.yml?branch=master\u0026style=flat-square\n\n[coveralls-url]: https://coveralls.io/r/VovanR/toggle-in-array\n[coveralls-image]: https://img.shields.io/coveralls/VovanR/toggle-in-array.svg?style=flat-square\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvovanr%2Ftoggle-in-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvovanr%2Ftoggle-in-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvovanr%2Ftoggle-in-array/lists"}