{"id":22021583,"url":"https://github.com/lamansky/vadd","last_synced_at":"2026-04-11T06:02:48.210Z","repository":{"id":57390020,"uuid":"134624807","full_name":"lamansky/vadd","owner":"lamansky","description":"[Node.js] Adds one or more values to an Array, Set, or other collection.","archived":false,"fork":false,"pushed_at":"2018-05-23T20:59:22.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-17T03:06:48.564Z","etag":null,"topics":[],"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/lamansky.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":"2018-05-23T20:58:41.000Z","updated_at":"2018-05-23T20:59:24.000Z","dependencies_parsed_at":"2022-09-15T05:20:27.571Z","dependency_job_id":null,"html_url":"https://github.com/lamansky/vadd","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lamansky/vadd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fvadd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fvadd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fvadd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fvadd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamansky","download_url":"https://codeload.github.com/lamansky/vadd/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fvadd/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263175725,"owners_count":23425628,"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":[],"created_at":"2024-11-30T06:13:06.320Z","updated_at":"2025-12-30T22:18:32.710Z","avatar_url":"https://github.com/lamansky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vadd\n\nAdds one or more values to an Array, Set, or other collection.\n\n## Installation\n\nRequires [Node.js](https://nodejs.org/) 8.3.0 or above.\n\n```bash\nnpm i vadd\n```\n\n## API\n\nThe module exports an `add()` function that has one other function attached to it as a method: `add.all()`.\n\n### `add()`\n\n#### Parameters\n\n1. Bindable: `collection` (Array, Set, or WeakSet): The collection to which to add a value.\n2. `valueToAdd` (any): The value to add to the end of the collection.\n3. Optional: Object argument:\n    * `arrays` / `sets` / `weakSets` (arrays of classes/strings): Arrays of classes and/or string names of classes that should be treated as equivalent to `Array`/`Set`/`WeakSet` (respectively).\n    * `index` (integer): The index at which to splice the new values. Only applies if `collection` is an Array. To insert values at the end, either omit the argument or set it to `-0` (negative zero).\n    * `loose` (boolean): Whether or not to compare values loosely (as defined by `looselyEquals`) for the purpose of testing uniqueness if `unique` is `true`. Defaults to `false`.\n    * `looselyEquals` (function): A callback that accepts two values and returns `true` if they are to be considered equivalent or `false` otherwise. This argument is only used if `loose` is `true`. If omitted, the default behavior will, among other things, consider arrays/objects to be equal if they have the same entries.\n    * `unique` (boolean): Whether or not to refrain from adding values that already exist in the collection. Defaults to `false`. You can define what uniqueness means by using the `loose` and `looselyEquals` arguments.\n\n#### Return Value\n\nThe number of items added (either `0` or `1`).\n\n#### Example\n\n```javascript\nconst add = require('vadd')\n\nconst arr = [1]\nadd(arr, 2) // [1, 2]\nadd(arr, 0, {index: 0}) // [0, 1, 2]\n```\n\n### `add.all()`\n\nUse this function if you want to add multiple values to a collection at once. The signature is the same as the main function except that the second parameter is called `valuesToAdd` and takes an iterable (such as an array). The return value is the total number of items added.\n\n#### Example\n\n```javascript\nconst add = require('vadd')\n\nconst set = new Set()\n\nadd.all(set, [1, 2, 3])\n\nset.has(1) // true\nset.has(2) // true\nset.has(3) // true\n```\n\n## Related\n\nThe “k” family of modules works on keyed/indexed collections.\n\n* [khas](https://github.com/lamansky/khas)\n* [kget](https://github.com/lamansky/kget)\n* [kedit](https://github.com/lamansky/kedit)\n* [kset](https://github.com/lamansky/kset)\n* [kinc](https://github.com/lamansky/kinc)\n* [kdel](https://github.com/lamansky/kdel)\n\nThe “v” family of modules works on any collection of values.\n\n* [vhas](https://github.com/lamansky/vhas)\n* [vget](https://github.com/lamansky/vget)\n* [vsize](https://github.com/lamansky/vsize)\n* [vdel](https://github.com/lamansky/vdel)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fvadd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamansky%2Fvadd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fvadd/lists"}