{"id":19267047,"url":"https://github.com/mljs/pad-array","last_synced_at":"2025-04-21T19:32:33.225Z","repository":{"id":36226327,"uuid":"40530632","full_name":"mljs/pad-array","owner":"mljs","description":"Array padding","archived":false,"fork":false,"pushed_at":"2019-06-29T13:03:42.000Z","size":29,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-10T18:10:53.246Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mljs.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","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":"2015-08-11T08:30:03.000Z","updated_at":"2019-06-29T13:03:44.000Z","dependencies_parsed_at":"2022-09-09T11:40:45.346Z","dependency_job_id":null,"html_url":"https://github.com/mljs/pad-array","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fpad-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fpad-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fpad-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fpad-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mljs","download_url":"https://codeload.github.com/mljs/pad-array/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250120083,"owners_count":21378135,"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-09T20:09:50.962Z","updated_at":"2025-04-21T19:32:33.219Z","avatar_url":"https://github.com/mljs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pad-array\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![npm download][download-image]][download-url]\n\nFunction to fill an array in JavaScript.\n\nThis code is based in the MATLAB's code [padarray](http://www.mathworks.com/help/images/ref/padarray.html)\n\n## Installation\n\n`npm i ml-pad-array`\n\n## pad-array(data, [options])\n\nPads the `data` array given the current `options` (returns a new array).\n\n**Options**:\n\n- **size**: Defines the number of fields that will be expanded. The default value is 1. The possible type values are:\n  - Number: If the value is just a number it will expand in all directions with that value.\n  - Array of numbers: It will expand in each direction given the values, for the array case the two values are `left and right` and for the matrix case are `left, up, right, down`\n- **value**: Determine how to fill the values, if the value don't match with the next strings, the new values are going to be filled with that value. The default value is 0. The special strings are:\n  - `'circular'`: Pad with circular repetition of elements within the dimension.\n  - `'replicate'`: Pad by repeating border elements of array.\n  - `'symmetric'`: Pad array with mirror reflections of itself. In this case the `size` shouldn't be bigger than the dimensions.\n- **output**: Instead of creating a new array, the returned value should be in this variable.\n\n## Examples\n\n```js\nvar data = [1, 2, 3, 4];\n\n// default case\nvar default_case = padArray(data);\ndefault_case === [0, 1, 2, 3, 4, 0];\n\n// circular case\nvar circular_case = padArray(data, { size: 5, value: 'circular' });\ncircular_case === [4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1];\n\n// replicate case\nvar replicate_case = padArray(data, { size: 3, value: 'replicate' });\nreplicate_case === [1, 1, 1, 1, 2, 3, 4, 4, 4, 4];\n\n// symmetric case\nvar symmetric_case = padArray(data, { size: 3, value: 'symmetric' });\nsymmetric_case === [3, 2, 1, 1, 2, 3, 4, 4, 3, 2];\n```\n\n## Authors\n\n- [Miguel Asencio](https://github.com/maasencioh)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/ml-pad-array.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/ml-pad-array\n[travis-image]: https://img.shields.io/travis/mljs/pad-array/master.svg?style=flat-square\n[travis-url]: https://travis-ci.org/mljs/pad-array\n[download-image]: https://img.shields.io/npm/dm/ml-pad-array.svg?style=flat-square\n[download-url]: https://npmjs.org/package/ml-pad-array\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fpad-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmljs%2Fpad-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fpad-array/lists"}