{"id":22021471,"url":"https://github.com/lamansky/follows-order","last_synced_at":"2026-04-11T13:10:09.799Z","repository":{"id":57239738,"uuid":"82097510","full_name":"lamansky/follows-order","owner":"lamansky","description":"Checks that specific array elements or string characters appear only in a certain order. Packaged as a Node.js module.","archived":false,"fork":false,"pushed_at":"2017-02-15T19:27:37.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T23:46:54.249Z","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/lamansky.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-15T19:22:22.000Z","updated_at":"2017-02-15T19:27:54.000Z","dependencies_parsed_at":"2022-08-29T21:23:25.509Z","dependency_job_id":null,"html_url":"https://github.com/lamansky/follows-order","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/lamansky%2Ffollows-order","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Ffollows-order/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Ffollows-order/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Ffollows-order/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamansky","download_url":"https://codeload.github.com/lamansky/follows-order/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245084862,"owners_count":20558294,"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-30T06:12:13.294Z","updated_at":"2025-12-30T23:34:32.375Z","avatar_url":"https://github.com/lamansky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# follows-order\n\nChecks that specific array elements or string characters appear only in a certain order. Packaged as a [Node.js](https://nodejs.org/) module.\n\n## Installation\n\n```bash\nnpm install follows-order --save\n```\n\nThe module exposes a single function.\n\n## Usage\n\n### Array Example\n\n```javascript\nconst followsOrder = require('follows-order')\n\nconst data = {\n  name: \"Test\",\n  description: \"This is a test\",\n  module: \"follows-order\",\n}\n\n// Check to make sure that `name` precedes `description`.\n// (Note: JavaScript does not guarantee object key order.\n// This is only for the sake of example.)\nfollowsOrder(Object.keys(data), ['name', 'description']) // true\n```\n\n### String Example\n\n```javascript\nconst followsOrder = require('follows-order')\n\nconst data = 'test'\n\n// Does the first \"t\" come before the first \"e\"?\nfollowsOrder(data, 'te') // true\n```\n\n### A Note on Duplicates\n\nIf an array or string is being checked to see if its order follows [A, B], then the first B cannot appear before the first A does, even if the [A, B] pattern occurs later.\n\nThis is according to design: the module is made to enforce a certain order, not merely check for a pattern.\n\n| Data         | Order     | Result | Reason |\n| ------------ | --------- | ------ | ------ |\n| [B,A,B]      | [A,B]     | Fail   | The first instance of A should have preceded the first instance of B. |\n| [A,B,B,A]    | [A,B]     | Pass   | A and B only occur once in the order, so only the first instances in the data are checked. |\n| [A,B,B,A]    | [A,B,A,B] | Fail   | A and B occur twice in the order, so the second A in the data should have preceded the second B. |\n\n```javascript\nconst followsOrder = require('follows-order')\n\nconst data = [1, 2, 1]\n\nfollowsOrder(data, [1, 2]) // true\nfollowsOrder(data, [2, 1]) // false, because in the data the first instance of 1 occurs before 2\nfollowsOrder(data, [1, 2, 1]) // true\n```\n\nIf you don’t want to deal with duplicate elements in your data, you’ll need to [deduplicate](https://github.com/lamansky/deduplicate) the data yourself before you check it with `follows-order`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Ffollows-order","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamansky%2Ffollows-order","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Ffollows-order/lists"}