{"id":15647432,"url":"https://github.com/jonschlinkert/pad-left","last_synced_at":"2025-04-09T15:06:36.575Z","repository":{"id":23964677,"uuid":"27347019","full_name":"jonschlinkert/pad-left","owner":"jonschlinkert","description":"Left pad a string with zeros or a specified string. Fastest implementation.","archived":false,"fork":false,"pushed_at":"2022-01-17T05:27:58.000Z","size":36,"stargazers_count":44,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T15:06:24.862Z","etag":null,"topics":["fill","left","pad","repeat","string"],"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/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-30T19:21:24.000Z","updated_at":"2022-12-06T01:07:32.000Z","dependencies_parsed_at":"2022-07-30T05:18:00.388Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/pad-left","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpad-left","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpad-left/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpad-left/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fpad-left/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/pad-left/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248055284,"owners_count":21040157,"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":["fill","left","pad","repeat","string"],"created_at":"2024-10-03T12:19:25.429Z","updated_at":"2025-04-09T15:06:36.551Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":["Modules","模块"],"sub_categories":["String"],"readme":"# pad-left [![NPM version](https://img.shields.io/npm/v/pad-left.svg?style=flat)](https://www.npmjs.com/package/pad-left) [![NPM downloads](https://img.shields.io/npm/dm/pad-left.svg?style=flat)](https://npmjs.org/package/pad-left) [![Build Status](https://img.shields.io/travis/jonschlinkert/pad-left.svg?style=flat)](https://travis-ci.org/jonschlinkert/pad-left)\n\nLeft pad a string with zeros or a specified string. Fastest implementation.\n\nYou might also be interested in [word-wrap](https://github.com/jonschlinkert/word-wrap).\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install pad-left --save\n```\n\n## Usage\n\n```js\nvar pad = require('pad-left');\npad(  '4', 4, '0') // 0004\npad( '35', 4, '0') // 0035\npad('459', 4, '0') // 0459\n```\n\n## Benchmarks\n\nBenchmarks for node.js v6.5.0 versus [left-pad](https://github.com/stevemao/left-pad).\n\n```sh\n# benchmark/fixtures/10-custom-char.js (37 bytes)\n  pad-left x 14,660,838 ops/sec ±1.43% (84 runs sampled)\n  left-pad x 9,189,792 ops/sec ±1.36% (81 runs sampled)\n\n# benchmark/fixtures/10.js (32 bytes)\n  pad-left x 13,357,570 ops/sec ±1.91% (84 runs sampled)\n  left-pad x 20,375,277 ops/sec ±1.40% (82 runs sampled)\n\n# benchmark/fixtures/100-custom-char.js (38 bytes)\n  pad-left x 13,671,301 ops/sec ±1.58% (83 runs sampled)\n  left-pad x 8,917,004 ops/sec ±1.84% (79 runs sampled)\n\n# benchmark/fixtures/100.js (34 bytes)\n  pad-left x 15,442,944 ops/sec ±1.68% (81 runs sampled)\n  left-pad x 7,850,636 ops/sec ±1.47% (83 runs sampled)\n\n# benchmark/fixtures/1000-custom-char.js (40 bytes)\n  pad-left x 13,624,072 ops/sec ±1.25% (84 runs sampled)\n  left-pad x 5,907,915 ops/sec ±1.13% (86 runs sampled)\n\n# benchmark/fixtures/1000.js (35 bytes)\n  pad-left x 14,241,788 ops/sec ±1.23% (81 runs sampled)\n  left-pad x 5,418,351 ops/sec ±1.52% (80 runs sampled)\n\n```\n\n## Related projects\n\nYou might also be interested in these projects:\n\n* [align-text](https://www.npmjs.com/package/align-text): Align the text in a string. | [homepage](https://github.com/jonschlinkert/align-text)\n* [center-align](https://www.npmjs.com/package/center-align): Center-align the text in a string. | [homepage](https://github.com/jonschlinkert/center-align)\n* [justified](https://www.npmjs.com/package/justified): Wrap words to a specified length and justified the text. | [homepage](https://github.com/jonschlinkert/justified)\n* [pad-right](https://www.npmjs.com/package/pad-right): Right pad a string with zeros or a specified string. Fastest implementation. | [homepage](https://github.com/jonschlinkert/pad-right)\n* [repeat-string](https://www.npmjs.com/package/repeat-string): Repeat the given string n times. Fastest implementation for repeating a string. | [homepage](https://github.com/jonschlinkert/repeat-string)\n* [right-align-keys](https://www.npmjs.com/package/right-align-keys): Right align the keys of an object. | [homepage](https://github.com/jonschlinkert/right-align-keys)\n* [right-align-values](https://www.npmjs.com/package/right-align-values): Right align the values of a given property for each object in an array. Useful… [more](https://www.npmjs.com/package/right-align-values) | [homepage](https://github.com/jonschlinkert/right-align-values)\n* [right-align](https://www.npmjs.com/package/right-align): Right-align the text in a string. | [homepage](https://github.com/jonschlinkert/right-align)\n* [right-pad-keys](https://www.npmjs.com/package/right-pad-keys): Right pad the keys of an object. | [homepage](https://github.com/jonschlinkert/right-pad-keys)\n* [right-pad-values](https://www.npmjs.com/package/right-pad-values): Right pad the values of a given property for each object in an array. Useful… [more](https://www.npmjs.com/package/right-pad-values) | [homepage](https://github.com/jonschlinkert/right-pad-values)\n* [word-wrap](https://www.npmjs.com/package/word-wrap): Wrap words to a specified length. | [homepage](https://github.com/jonschlinkert/word-wrap)\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/pad-left/issues/new).\n\n## Building docs\n\nGenerate readme and API documentation with [verb](https://github.com/verbose/verb):\n\n```sh\n$ npm install verb \u0026\u0026 npm run docs\n```\n\nOr, if [verb](https://github.com/verbose/verb) is installed globally:\n\n```sh\n$ verb\n```\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm install -d \u0026\u0026 npm test\n```\n\n## Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n## License\n\nCopyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT license](https://github.com/jonschlinkert/pad-left/blob/master/LICENSE).\n\n***\n\n_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 07, 2016._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fpad-left","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fpad-left","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fpad-left/lists"}