{"id":15387160,"url":"https://github.com/wildhoney/bi-cycle","last_synced_at":"2025-04-15T20:16:10.482Z","repository":{"id":142000454,"uuid":"55061250","full_name":"Wildhoney/Bi-cycle","owner":"Wildhoney","description":"Bi-cycle assists in making infinite carousels and sliders by handling the index logic for you.","archived":false,"fork":false,"pushed_at":"2017-02-16T09:16:12.000Z","size":101,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T20:16:02.927Z","etag":null,"topics":["counter","decrement","generator","increment","range","slide","slider"],"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/Wildhoney.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,"governance":null}},"created_at":"2016-03-30T12:31:19.000Z","updated_at":"2019-07-15T22:54:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"4bd35c8c-2ed3-4298-8ebc-38bee98c28a4","html_url":"https://github.com/Wildhoney/Bi-cycle","commit_stats":{"total_commits":48,"total_committers":1,"mean_commits":48.0,"dds":0.0,"last_synced_commit":"01d7d199a147b80b78085a7dbfebea35949282ba"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wildhoney%2FBi-cycle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wildhoney%2FBi-cycle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wildhoney%2FBi-cycle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wildhoney%2FBi-cycle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wildhoney","download_url":"https://codeload.github.com/Wildhoney/Bi-cycle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249145420,"owners_count":21219966,"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":["counter","decrement","generator","increment","range","slide","slider"],"created_at":"2024-10-01T14:52:19.058Z","updated_at":"2025-04-15T20:16:10.455Z","avatar_url":"https://github.com/Wildhoney.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bi-cycle\n\n\u003e Bi-cycle assists in making infinite carousels and sliders by handling the index logic for you.\n\n![Travis](http://img.shields.io/travis/Wildhoney/Bi-cycle.svg?style=flat-square)\n\u0026nbsp;\n![npm](http://img.shields.io/npm/v/bi-cycle.svg?style=flat-square)\n\u0026nbsp;\n![License MIT](http://img.shields.io/badge/License-MIT-lightgrey.svg?style=flat-square)\n\n**npm:** `npm i bi-cycle`\n\n\u003cimg src=\"https://sketchedout.files.wordpress.com/2007/11/fishbike.jpg?w=480\" width=\"300\" /\u003e\n\n**Source:** [SketchedOut](https://sketchedout.wordpress.com/tag/like-a-fish-needs-a-bicycle/)\n\n## Getting Started\n\nBi-cycle uses [generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators) and provides an interface to modify the immutable index.\n\n**Note:** `Bi-cycle` is more a proof of concept for not mutating values using generators, however you're more than welcome to use it in production.\n\n```javascript\nimport Bicycle from 'bi-cycle';\n\n// ...\n\nconst { next, previous } = Bicycle({ start: 0, max: 5, infinite: true });\n\nnextButton.addEventListener('click', next);\npreviousButton.addEventListener('click', previous);\n```\n\nThere are handful of functions which can be destructured for modifying the state:\n\n * `next` Moves either to the next index, or to `min` if at `max`;\n * `previous` Moves either to the previous index, or to `max` if at `min`;\n * `first` Moves to `min`;\n * `last` Moves to `max` \u0026ndash; by default `Infinity`;\n * `set(n)` Sets slide denoted by `n` otherwise `min` or `max` if out of range;\n \nYou may also pass in additional parameters to `Bicycle` in order to override the defaults:\n\n * `start` Determines the initial index value \u0026ndash; default is `min`;\n * `min` Determines the first index \u0026ndash; default is `-Infinity`;\n * `max` Determines the last index \u0026ndash; default is `Infinity`;\n * `infinite` Determines the action of Bi-cycle when the index is our of range \u0026ndash; default is `true`;\n\n## Unique ID\n\nAnother use for Bi-cycle is a slightly over-elaborate unique ID generator \u0026ndash; each and every time you invoke `next` a unique number is returned.\n\n```javascript\nimport Bicycle from 'bi-cycle';\n\nconst { next } = Bicycle();\n\nconst createModel = name =\u003e {\n    return { id: next(), name };\n};\n\ncreateModel('Adam'); // { id: 1, name: 'Adam' }\ncreateModel('Maria'); // { id: 2, name: 'Maria' }\ncreateModel('Igba'); // { id: 3, name: 'Igba' }\n```\n\n[![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](http://forthebadge.com)\n\nReleased under the [MIT license](https://github.com/Wildhoney/Bi-cycle/blob/master/LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwildhoney%2Fbi-cycle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwildhoney%2Fbi-cycle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwildhoney%2Fbi-cycle/lists"}