{"id":22021576,"url":"https://github.com/lamansky/ltrim-array","last_synced_at":"2026-04-12T18:57:23.846Z","repository":{"id":92611984,"uuid":"120186257","full_name":"lamansky/ltrim-array","owner":"lamansky","description":"[Node.js] Removes specified values from the beginning of an array.","archived":false,"fork":false,"pushed_at":"2018-02-04T13:25:44.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T16:45:12.460Z","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-04T13:15:42.000Z","updated_at":"2018-02-04T13:25:45.000Z","dependencies_parsed_at":"2023-04-12T04:02:51.368Z","dependency_job_id":null,"html_url":"https://github.com/lamansky/ltrim-array","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fltrim-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fltrim-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fltrim-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Fltrim-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamansky","download_url":"https://codeload.github.com/lamansky/ltrim-array/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245085062,"owners_count":20558327,"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:00.744Z","updated_at":"2026-04-12T18:57:18.787Z","avatar_url":"https://github.com/lamansky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ltrim-array\n\nRemoves specified values from the beginning of an array. Analogous to a left-trim operation for strings, except this module tests array elements instead of string characters.\n\n## Installation\n\nRequires [Node.js](https://nodejs.org/) 6.0.0 or above.\n\n```bash\nnpm i ltrim-array\n```\n\n## API\n\nThe module exports a single function.\n\n### Parameters\n\n1. Bindable: `arr` (Array or Array-like): The array that might have starting elements to be removed.\n2. Optional: `trim` (any): A Function that tests elements (returning `true` if the element should be trimmed), or an Array of elements to be trimmed, or any single value that should be trimmed. If this argument is omitted, then `undefined` will be trimmed.\n\n### Return Value\n\nA copy of `arr`, with any trimmable elements removed from the beginning.\n\n## Examples\n\nBy default, `ltrimArray()` removes `undefined` elements from the beginning of an array.\n\n```javascript\nconst ltrimArray = require('ltrim-array')\nltrimArray([undefined, undefined, 1, 2, 3]) // [1, 2, 3]\n```\n\nThis operation is distinct from that of `Array.prototype.filter()` because `ltrimArray()` only removes from the beginning. If a trimmable value (in this case, `undefined`) is found at the end or in the middle of the array, it will not be removed:\n\n```javascript\nltrimArray([undefined, undefined, 1, undefined, 3]) // [1, undefined, 3]\n```\n\nIf you want to trim something besides `undefined`, provide it as the second argument:\n\n```javascript\nltrimArray([null, undefined, 1, 2, 3], null) // [undefined, 1, 2, 3]\n```\n\nIf you want more than one value to be trimmed, put the values in an array and provide it as the second argument:\n\n```javascript\nltrimArray([null, false, null, 1, 2, 3], [false, null]) // [1, 2, 3]\n```\n\nTo do more advanced filtering, provide a callback. Each element at the beginning will be passed to the callback, and if the callback returns true, the element will be trimmed. If the callback returns false, the trimming will stop. In this example, the callback causes the module to trim numbers from the beginning, stopping when it reaches the string:\n\n```javascript\nltrimArray([1, 2, 3, '4', 5], el =\u003e typeof el === 'number') // ['4', 5]\n```\n\nIf every element in the array is trimmable, an empty array will be returned:\n\n```javascript\nltrimArray([undefined]) // []\n```\n\nThe module also supports the bind operator:\n\n```javascript\nconst ltrim = require('ltrim-array')\n[undefined, undefined, 1, 2, 3]::ltrim() // [1, 2, 3]\n[null, undefined, 1, 2, 3]::ltrim(null)  // [undefined, 1, 2, 3]\n```\n\n## Related\n\n* [rtrim-array](https://github.com/lamansky/rtrim-array): Removes specified values from the end of an array.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fltrim-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamansky%2Fltrim-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Fltrim-array/lists"}