{"id":18687319,"url":"https://github.com/junosuarez/node-nonblocking","last_synced_at":"2025-11-08T02:30:31.365Z","repository":{"id":65424813,"uuid":"51136674","full_name":"junosuarez/node-nonblocking","owner":"junosuarez","description":"Array.prototype functions that won't block on large arrays","archived":false,"fork":false,"pushed_at":"2016-02-26T01:10:40.000Z","size":7,"stargazers_count":2,"open_issues_count":3,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-15T16:46:20.147Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/nonblocking","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/junosuarez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-05T09:08:26.000Z","updated_at":"2020-08-28T14:28:31.000Z","dependencies_parsed_at":"2023-01-23T02:05:10.153Z","dependency_job_id":null,"html_url":"https://github.com/junosuarez/node-nonblocking","commit_stats":null,"previous_names":["jden/node-nonblocking"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fnode-nonblocking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fnode-nonblocking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fnode-nonblocking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junosuarez%2Fnode-nonblocking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/junosuarez","download_url":"https://codeload.github.com/junosuarez/node-nonblocking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239545335,"owners_count":19656763,"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-07T10:32:27.052Z","updated_at":"2025-11-08T02:30:31.334Z","avatar_url":"https://github.com/junosuarez.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nonblocking\nArray.prototype functions that won't block on large arrays\n\n[![js standard style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)]()\n\n[![build status](https://circleci.com/gh/jden/node-nonblocking.svg?\u0026style=shield)][circleci]\n\n[circleci]: https://circleci.com/gh/jden/node-nonblocking\n[standard]: http://standardjs.com/\n\n## usage\n```js\nvar nonblocking = require('nonblocking')\n\nvar bigArray = []\nfor (var i; i \u003c 10000000; i++) {\n  bigArray.push(i)\n}\n\nnonblocking(bigArray).forEach(function (el) {\n  console.log(el)\n}, function (err) {\n  console.log('all done!')\n})\n\n```\n\nWhen iterating over large arrays, even simple functions\nmay become blocking. In a browser, this might mean an\nslow, \"janky\" page. In Node.js, this might mean a\ncompletely non-responsive web server!\n\nUse this module to fan out over a large array. Note\nthat the functions being applied to each element are\nnot treated asynchronously or in parallel, so it's\nnot suited to file system or network IO. If that's\nwhat you want, consider the popular [`async`][1] module.\n\nMeasure before optimizing! You can use the [`event-loop-lag`][2] module to measure if you have anything blocking in your Node.js process. If those numbers start\nto rise, `nonblocking` might help you!\n\n[1]: https://www.npmjs.com/package/async\n[2]: https://www.npmjs.com/package/event-loop-lag\n\n## api\n\nIn brief, call any of `filter`, `forEach`, `some`, `every`, or `map`, passing the array as the first arugment, and a Node.js-style callback as the last.\n\nThe methods are also available in a fluent syntax like lodash or underscore. Use whichever one you prefer.\n\nUsing [jsig](https://github.com/jsigbiz/spec) annotation.\n\n**`filter` and `forEach` also accept Dictionary objects.** Other functions may support operating on Dictionaries in the future\n\n### `forEach(arr: Array | Dictionary, fn: Function) =\u003e Callback\u003c\u003e`\n\nThe final callback parameter is optional.\n\ne.g.\n```js\nnonblocking.forEach([1, 2, 3], function (x) {\n  console.log(x)\n}, function (err) {\n  // logged: 1\\n2\\n3\n})\n\n// or \n\nnonblocking([1, 2, 3]).forEach(function (x) {\n  console.log(x)\n}, function (err) {\n  // logged: 1\\n2\\n3\n})\n\n// Dictionary usage\n\nnonblocking({a: 1, b: 2, c: 3}).forEach(function (val, key) {\n  console.log(key, val)\n}, function (err) {\n  // logged: \"a\" 1\\n\"b\" 2\\n\"c\" 3\n})\n```\n\n\n### `filter(arr: Array | Dictionary, fn: Predicate) =\u003e Callback\u003cArray\u003e`\n\ne.g.\n```js\nnonblocking.filter([1, 2, 3], function (x) { return x \u003e= 2 }, function (err, out) {\n  // out = [2, 3]\n})\n\n// or \n\nnonblocking([1, 2, 3]).filter(function (x) { return x \u003e= 2 }, function (err, out) {\n  // out = [2, 3]\n})\n\n// Dictionary usage\n\nnonblocking({a: 1, b: 2, c: 3]).filter(function (val, key) { return val \u003e= 2 }, function (err, out) {\n  // out = {b: 2, c: 3}\n})\n```\n\n\n### `map(arr: Array, fn: Function) =\u003e Callback\u003cArray\u003e`\n\ne.g.\n```js\nnonblocking.map([1, 2, 3], function (x) { return x + 1 }, function (err, out) {\n  // out = [2, 3, 4]\n})\n\n// or \n\nnonblocking([1, 2, 3]).map(function (x) { return x + 1 }, function (err, out) {\n  // out = [2, 3, 4]\n})\n```\n\n\n### `some(arr: Array, fn: Predicate) =\u003e Callback\u003cBoolean\u003e`\n\ne.g.\n```js\nnonblocking.some([1, 2, 3], function (x) { return x \u003c 0 }, function (err, out) {\n  // out = false\n})\n\n// or \n\nnonblocking([1, 2, 3]).some(function (x) { return x \u003c 0 }, function (err, out) {\n  // out = false\n})\n```\n\n\n### `every(arr: Array, fn: Predicate) =\u003e Callback\u003cBoolean\u003e`\n\ne.g.\n```js\nnonblocking.every([1, 2, 3], function (x) { return x \u003e 0 }, function (err, out) {\n  // out = true\n})\n\n// or \n\nnonblocking([1, 2, 3]).every(function (x) { return x \u003e 0 }, function (err, out) {\n  // out = true\n})\n```\n\n\n## installation\n\n    $ npm install nonblocking\n\n\n## running the tests\n\nFrom package root:\n\n    $ npm install\n    $ npm test\n\n\n## contributors\n\n- jden \u003cjason@denizac.org\u003e\n\n\n## license\n\nISC. (c) MMXVI jden \u003cme@jden.us\u003e. See LICENSE.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunosuarez%2Fnode-nonblocking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunosuarez%2Fnode-nonblocking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunosuarez%2Fnode-nonblocking/lists"}