{"id":16760394,"url":"https://github.com/ryanve/cueing","last_synced_at":"2025-03-16T09:16:51.640Z","repository":{"id":16601162,"uuid":"19355729","full_name":"ryanve/cueing","owner":"ryanve","description":"JavaScript utility to cue, seek, or cycle items","archived":false,"fork":false,"pushed_at":"2017-03-12T01:28:14.000Z","size":30,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"gh-pages","last_synced_at":"2025-03-15T21:51:21.246Z","etag":null,"topics":["arrays","cycle","cycler","javascript","module","playlists"],"latest_commit_sha":null,"homepage":"http://ryanve.dev/cueing/","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/ryanve.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-05-01T19:48:00.000Z","updated_at":"2024-02-04T18:31:18.000Z","dependencies_parsed_at":"2022-09-24T08:40:34.157Z","dependency_job_id":null,"html_url":"https://github.com/ryanve/cueing","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fcueing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fcueing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fcueing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fcueing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanve","download_url":"https://codeload.github.com/ryanve/cueing/tar.gz/refs/heads/gh-pages","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847056,"owners_count":20357317,"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":["arrays","cycle","cycler","javascript","module","playlists"],"created_at":"2024-10-13T04:23:22.460Z","updated_at":"2025-03-16T09:16:51.607Z","avatar_url":"https://github.com/ryanve.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cueing \u0026#9658;\u0026#9658;|\nCue, seek, or cycle items in JavaScript in node or the browser\n\n### [npm](https://www.npmjs.com/package/cueing)\n```\nnpm install cueing --save\n```\n\n### Basic usage\n\n```js\nvar cueing = require('cueing')\nvar letters = cueing(['a', 'b', 'c'])\n\n// cue the last index and then read from there\nletters.cue(-1) // =\u003e letters\nletters.seek(0) // =\u003e 'c'\nletters.seek(1) // =\u003e 'a'\n\n// manually move the needle\nletters.needle(0)\n\n// seek backwards\nletters.seek(-1) // =\u003e 'c'\n\n// seeking (or cueing) will loop around\nletters.seek(-4) // =\u003e 'b'\n```\n\n## API\n\n### `cueing(pool=[])`\n- Get a new `cueing` instance\n- `pool`: `number|{length:number}` length or array(-like) of values\n- \u0026rarr; `cueing` instance\n\n#### `cueing()` instances are array-like and inherit array methods\n\n```js\nvar tracks = cueing(['1.mp3', '2.mp3', '3.mp3'])\ntracks.join() // '1.mp3,2.mp3,3.mp3'\ntracks instanceof cueing // true\ntracks instanceof Array // true\nArray.isArray(tracks) // false\n\ncueing(3).every(function(v, i, range) {\n  // Cueing objects are made dense for use with array iterators\n  return undefined === v \u0026\u0026 i in range \u0026\u0026 range instanceof cueing\n}) // true\n```\n\n#### `cueing()` objects coerce to their needle position\n\n```js\nvar cueing = require('cueing')\nvar list = cueing(['a', 'b', 'c'])\n+list // 0\nisFinite(list) // true\nlist.needle(2) // move the needle to a new index\n2 == list // true\n+list // 2\nString(list) // '2'\nlist[list] // 'c'\n```\n\n### `cueing()` methods\n\n#### `.needle(index?)`\n- Manually move the needle to `index`\n- `index`: `number|cueing` destination index\n- \u0026rarr; `this`\n\n#### `.cue(offset=0)`\n- Move the needle by `offset`\n- `offset`: `number|cueing` +/- integer to move the needle by\n- \u0026rarr; `this`\n\n#### `.seek(offset=0)`\n- `.cue` the offset and get the value there\n- `offset`: `number|cueing` +/- integer to move the needle by\n- \u0026rarr; `*`\n\n#### `.store()`\n- Store the current needle position for recalling later\n- \u0026rarr; `this`\n\n#### `.recall(index?)`\n- Recall stored cue point(s)\n- `index`: `number|cueing` +/- index to read. `0` reads the oldest point. `-1` reads the newest.\n- \u0026rarr; `cueing` instance at recalled state\n\n#### `.clear()`\n- Clear stored cue points\n- \u0026rarr; `this`\n\n#### `.clone()`\n- Clone (copy) a `cueing` instance at its current state to a new instance\n- \u0026rarr; `cueing` clone\n\n### Static methods\n\n#### `cueing.cue(pool, start=0, offset=0)`\n- Get the `pool` index that is `offset` away from `start`\n- \u0026rarr; `number`\n\n```js\ncueing.cue(['a', 'b', 'c'], -1) // =\u003e 2\ncueing.cue(['a', 'b', 'c'], 1, -2) // =\u003e 2\n```\n\n#### `cueing.seek(pool, start=0, offset=0)`\n- Get the `pool` value that is `offset` away from `start`\n- \u0026rarr; `*`\n\n```js\ncueing.seek(['a', 'b', 'c'], 1, -1) // =\u003e 'a'\ncueing.seek(['a', 'b', 'c'], 0, 5) // =\u003e 'b'\n```\n\n#### `cueing.store(array, point)`\n- Push `point` onto `array` if different from last point\n- \u0026rarr; `array` reference\n\n```js\ncueing.store([1, 5], 3) // =\u003e [1, 5, 3]\ncueing.store([1, 5], 5) // =\u003e [1, 5]\ncueing.store([1, 5], 1) // =\u003e [1, 5, 1]\n```\n\n## Playground\n[Try `cueing` in the browser](http://ryanve.github.io/cueing/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Fcueing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanve%2Fcueing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Fcueing/lists"}