{"id":22505267,"url":"https://github.com/azer/new-list","last_synced_at":"2025-07-27T11:35:47.554Z","repository":{"id":8082611,"uuid":"9496001","full_name":"azer/new-list","owner":"azer","description":"Array-like objects with PubSub interfaces that you can subscribe to changes.","archived":false,"fork":false,"pushed_at":"2013-06-25T19:14:09.000Z","size":176,"stargazers_count":17,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T23:20:33.399Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/azer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-17T11:33:23.000Z","updated_at":"2021-12-01T00:00:47.000Z","dependencies_parsed_at":"2022-09-18T00:40:31.171Z","dependency_job_id":null,"html_url":"https://github.com/azer/new-list","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/azer%2Fnew-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fnew-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fnew-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fnew-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azer","download_url":"https://codeload.github.com/azer/new-list/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228540839,"owners_count":17934031,"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-12-07T00:16:46.666Z","updated_at":"2024-12-07T00:16:47.336Z","avatar_url":"https://github.com/azer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## new-list ![Build Status](https://travis-ci.org/azer/new-list.png)\n\nArray-like objects with [PubSub](http://github.com/azer/pubsub) interfaces that you can subscribe to\nchanges. See also: [new-object](https://github.com/azer/new-object)\n\n```js\nList = require('new-list')\ntodo = List('Buy milk', 'Take shower')\n\ntodo.pop()\ntodo.push('Cook Dinner')\ntodo.splice(0, 1, 'Buy Milk And Bread')\n\ntodo(0)\n// =\u003e 'Buy Milk and Break'\ntodo(1)\n// =\u003e 'Take shower'\ntodo(1, 'Take a long shower')\ntodo(1)\n// =\u003e 'Take a long shower'\ntodo.len()\n// =\u003e 2\ntodo()\n// =\u003e ['Buy Milk and Bread', 'Take a long shower']\n\ntodo.subscribe(function(update){ // or todo.subscribe.once\n\n  update.add\n  // =\u003e { 0: 'Buy Milk And Bread', 1: 'Cook Dinner' }\n\n  update.remove\n  // =\u003e [0, 1]\n\n  update.sort\n  // =\u003e undefined\n\n})\n```\n\n## Install\n\n```bash\n$ npm install new-list\n```\n\n## Firing Custom Updates\n\n```js\npeople = List({ name: 'Joe', age: 27 }, { name: 'Smith', age: 19 })\n\npeople.subscribe(function(update){\n\n  if (update.person) {\n\n    update.index\n    // =\u003e 1\n\n    update.person\n    // =\u003e { name: 'Smith', age: 20 }\n\n  }\n\n})\n\npeople[1].age = 20\npeople.publish({ person: people[1], index: 1 })\n```\n\n## Iteration\n\n```js\nfruits = List('Apple', 'Orange', 'Banana')\n\ni = fruits.len()\n\nwhile( i --\u003e 0 ) {\n\n  fruits(i)\n  // =\u003e Apple (or Orange, Banana)\n\n  fruits.array[i]\n  // =\u003e Apple  (or Orange, Banana)\n\n}\n```\n\n## API Reference\n\n* **len()** Returns the length of the array. **Warning:* Never use *length* property.\n\n### Mutator Methods\n\n* **pop** Removes the last element from an array and returns that element.\n* **push** Adds one or more elements to the end of an array and returns the new length of the array.\n* **reverse** Reverses the order of the elements of an array -- the first becomes the last, and the last becomes the first.\n* **shift** Removes the first element from an array and returns that element.\n* **sort** Sorts the elements of an array.\n* **splice** Adds and/or removes elements from an array.\n* **unshift** Adds one or more elements to the front of an array and returns the new length of the array.\n\n### Accessor Methods\n\n* **concat** Returns a new array comprised of this array joined with other array(s) and/or value(s).\n* **join** Joins all elements of an array into a string.\n* **slice** Extracts a section of an array and returns a new array.\n* **toSource** Returns an array literal representing the specified array; you can use this value to create a new array. Overrides the Object.prototype.toSource method.\n* **toString** Returns a string representing the array and its elements. Overrides the Object.prototype.toString method.\n* **indexOf** Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.\n* **lastIndexOf** Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.\n\n### Iteration Methods\n\n* **forEach** Calls a function for each element in the array.\n* **every** Returns true if every element in this array satisfies the provided testing function.\n* **some** Returns true if at least one element in this array satisfies the provided testing function.\n* **filter** Creates a new array with all of the elements of this array for which the provided filtering function returns true.\n* **map** Creates a new array with the results of calling a provided function on every element in this array.\n* **reduce** Apply a function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value.\n* **reduceRight** Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value.\n\n![](https://dl.dropboxusercontent.com/s/gquje0z7y7oro4f/npmel_10.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazer%2Fnew-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazer%2Fnew-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazer%2Fnew-list/lists"}