{"id":16739220,"url":"https://github.com/pranaygp/proposal-array-prototype-do","last_synced_at":"2026-02-23T12:50:33.684Z","repository":{"id":78332445,"uuid":"105833603","full_name":"pranaygp/proposal-array-prototype-do","owner":"pranaygp","description":"tc39 array prototype do proposal","archived":false,"fork":false,"pushed_at":"2017-10-05T04:15:59.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-04T09:43:27.717Z","etag":null,"topics":["ecmascript","tc39"],"latest_commit_sha":null,"homepage":null,"language":null,"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/pranaygp.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-05T00:28:55.000Z","updated_at":"2017-10-05T01:05:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"edf710cc-7456-4269-805d-4f8574c0ad37","html_url":"https://github.com/pranaygp/proposal-array-prototype-do","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pranaygp/proposal-array-prototype-do","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranaygp%2Fproposal-array-prototype-do","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranaygp%2Fproposal-array-prototype-do/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranaygp%2Fproposal-array-prototype-do/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranaygp%2Fproposal-array-prototype-do/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pranaygp","download_url":"https://codeload.github.com/pranaygp/proposal-array-prototype-do/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranaygp%2Fproposal-array-prototype-do/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29743322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["ecmascript","tc39"],"created_at":"2024-10-13T00:49:24.588Z","updated_at":"2026-02-23T12:50:33.666Z","avatar_url":"https://github.com/pranaygp.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Array.prototype.do proposal\n\nThis proposal introduces a new method to the Javascript Array prototype to support the common use case of performing side effects while iterating through an Array, while returning the original array paramenter. It is a pretty useful tool to help with the case where one finds themselves having to leave the chainability of function calls like `.map`, `.filter` and `.reduce`\n\n## Inspiration\n\nRxJS is an awesome library that almost lets you treat asynchronous events as elements in an array (called an Observable). RxJS has a [similarly named method on `Observable`](http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-do) which is pretty useful.\n\n## Introduction\n\nThe `Array.prototype.do` method is essentially synctactic sugar on a call to `Array.prototyp.map` that performs side effects before returning the first parameter of the callback.\n\nFor example:\n\n```javascript\nmyArray.do(console.log)\n```\n\nis equivalent to \n\n```javascript\nmyArray.map(x =\u003e {\n  console.log(x);\n  return x;\n})\n```\n\n## Proposed API \n\n```javascript\narr.do(function callback(currentValue, index, array) {\n    // Return element for new_array\n}[, thisArg])\n```\n\n### Parameters\n\n`callback`\n  Function that performs the intended side effect, taking three arguments:\n\n  `currentValue`\n    The current element being processed in the array.\n\n  `index`\n    The index of the current element being processed in the array.\n\n  `array`\n    The array `do` was called upon.\n  \n`thisArg`\n  Optional. Value to use as `this` when executing callback.\n\n\n### Return value\n\nThe original array that `.do` was called on\n\n### Examples\n\nDebugging (example inspired from [RxJS docs](http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#instance-method-do)\n\n```javascript\nlet clicks = ... // events\nlet positions = clicks\n  .do(console.log)  // easy to add line when debugging\n  .map(ev =\u003e ev.clientX)\n```\n\nFiltering function applications\n\n```javascript\nlet allFiles = ... // list of files\nallFiles\n  .do(someFunctionForAllFiles)\n  .filter(s =\u003e s.endsWith('.js'))\n  .do(someFunctionForJSFilesOnly)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranaygp%2Fproposal-array-prototype-do","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpranaygp%2Fproposal-array-prototype-do","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranaygp%2Fproposal-array-prototype-do/lists"}