{"id":13659339,"url":"https://github.com/usablica/_s","last_synced_at":"2025-04-24T14:33:08.359Z","repository":{"id":18500590,"uuid":"21696758","full_name":"usablica/_s","owner":"usablica","description":"_s: Pythonic array slicing in JavaScript","archived":false,"fork":false,"pushed_at":"2014-08-04T18:38:20.000Z","size":266,"stargazers_count":72,"open_issues_count":2,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-21T03:47:41.878Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://usablica.github.io/_s","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/usablica.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-07-10T14:17:37.000Z","updated_at":"2023-07-09T18:34:18.000Z","dependencies_parsed_at":"2022-07-26T23:01:58.011Z","dependency_job_id":null,"html_url":"https://github.com/usablica/_s","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/usablica%2F_s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usablica%2F_s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usablica%2F_s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usablica%2F_s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/usablica","download_url":"https://codeload.github.com/usablica/_s/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249996019,"owners_count":21358046,"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-08-02T05:01:07.682Z","updated_at":"2025-04-24T14:33:07.531Z","avatar_url":"https://github.com/usablica.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"_s\n===\n\n\u003e Pythonic array slicing in JavaScript\n\n## Hello world\n\n```javascript\n_s([1,2,3,4,5,6], '0'); //returns [1]\n\n_s([1,2,3,4,5,6], '-1'); //returns [6]\n\n_s([1,2,3,4,5,6], '0:3'); //returns [1, 2, 3]\n\n_s([1,2,3,4,5,6], ':'); //returns [1, 2, 3, 4, 5, 6]\n```\n\n## How to install\n\n1. **NPM**\n\n    `npm install underscore-s`\n\n2. **Bower**\n\n    `bower install _s`\n\n3. Or download latest stable version from `https://github.com/usablica/_s/releases` and include `_s.js` or `minified/_s.min.js` for web browser production use. \n\nExamples:\n\n**Web browsers**:  \n\n```html\n\u003cscript src=\"_s.min.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n```\n\n**NodeJS**:  \n\n```javascript\n_s = require('underscore-s')._s;\n```\n\nThat's it.\n\n## How to use\n\nThe general scheme for `_s` is:\n\n    from:to:step\n\nAll values can be both positive and negative.\n\n### Get a single value\n\n```javascript\n_s([1, 2, 3, 4, 5, 6], '0'); //returns [1]\n_s([1, 2, 3, 4, 5, 6], '-1'); //returns [6]\n```\n\n### Get a range of values\n\n```javascript\n_s([1, 2, 3, 4, 5, 6], '0:3'); //returns [1, 2, 3]\n_s([1, 2, 3, 4, 5, 6], '-4:-1'); //returns [3, 4, 5]\n_s([1, 2 ,3 ,4 ,5 ,6], ':'); //returns [1, 2 ,3 ,4 ,5 ,6]. Makes a copy of original array\n```\n\n### Using step parameter\n\n```javascript\n_s([1, 2, 3, 4, 5, 6], '::1'); //returns [1,2,3,4,5,6]\n_s([1, 2, 3, 4, 5, 6], '::2'); //returns [1, 3, 5]\n_s([1, 2, 3, 4, 5, 6], '::-1'); //returns [6, 5, 4, 3, 2, 1]. Equal to array.reverse\n_s([1, 2, 3, 4, 5, 6], '0:4:2'); //returns [1, 3]\n_s([1, 2, 3, 4, 5, 6], '0:4:3'); //returns [1, 4]\n```\n\nFound something interesting? Please add it here :-)\n\n## Compatible environments\n#### Client-side:\n  - All major browsers including mobile browsers\n\n#### Service-side:\n  - All server-side platforms including NodeJS.\n\n## Roadmap\n- Add `String` slicing\n- Write unit tests\n\n## Release History\n\n * **v0.2.0** - 2014-07-04\n   - Remove prototype + add AMD/CommonJS module structure\n\n\n * **v0.1.0** - 2014-06-10\n   - Initial version\n\n## Author\n**Afshin Mehrabani**\n\n- [Twitter](https://twitter.com/afshinmeh)\n- [Github](https://github.com/afshinm)\n- [Personal page](http://afshinm.name/)\n\n## License\n\u003e Copyright (C) 2014 Afshin Mehrabani (afshin.meh@gmail.com)\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n    documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation\n    the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,\n    and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n    The above copyright notice and this permission notice shall be included in all copies or substantial portions\n    of the Software.\n    \n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\n    TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\n    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n    IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusablica%2F_s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fusablica%2F_s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusablica%2F_s/lists"}