{"id":17323070,"url":"https://github.com/danieleds/interval-match","last_synced_at":"2025-09-15T12:41:57.604Z","repository":{"id":57275346,"uuid":"67776276","full_name":"danieleds/interval-match","owner":"danieleds","description":"Library for matching a set of intervals with patterns","archived":false,"fork":false,"pushed_at":"2017-09-05T14:31:33.000Z","size":115,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-03T10:09:23.240Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/danieleds.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":"2016-09-09T07:21:28.000Z","updated_at":"2016-11-27T17:43:09.000Z","dependencies_parsed_at":"2022-09-15T19:12:42.057Z","dependency_job_id":null,"html_url":"https://github.com/danieleds/interval-match","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/danieleds/interval-match","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieleds%2Finterval-match","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieleds%2Finterval-match/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieleds%2Finterval-match/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieleds%2Finterval-match/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danieleds","download_url":"https://codeload.github.com/danieleds/interval-match/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieleds%2Finterval-match/sbom","scorecard":{"id":319595,"data":{"date":"2025-08-11","repo":{"name":"github.com/danieleds/interval-match","commit":"b1826a67473c2a658f725911dd14dda08d58d89f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T01:03:30.125Z","repository_id":57275346,"created_at":"2025-08-18T01:03:30.125Z","updated_at":"2025-08-18T01:03:30.125Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273755900,"owners_count":25162248,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-15T13:45:13.806Z","updated_at":"2025-09-15T12:41:57.582Z","avatar_url":"https://github.com/danieleds.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IntervalMatch\n\n[![npm version](https://badge.fury.io/js/interval-match.svg)](https://badge.fury.io/js/interval-match)\n[![Build Status](https://travis-ci.org/danieleds/interval-match.svg?branch=master)](https://travis-ci.org/danieleds/interval-match)\n\u003c!-- [![npm version](https://img.shields.io/npm/v/interval-match.svg?maxAge=2592000)](https://www.npmjs.com/package/interval-match)\n[![npm](https://img.shields.io/npm/dm/interval-match.svg?maxAge=2592000)]()--\u003e\n\nThis library allows you to match a set of intervals with various patterns.\n\n## Install\n\n```sh\n$ npm install --save interval-match\n```\n\n## Introduction\n\nIntervals are objects which define their position and a payload. For example, this is an interval:\n\n```js\n{\n    from: 10,\n    to: 15.7,\n    data: { some: 'thing' }\n}\n```\n\nWhen you have a set of intervals, you might need to find some of them based on their properties as a whole.\nThink of this process as similar to regular expressions: just like `a{1,3}b` will match any string composed by one, two or three *a's* followed by a *b*, you can write a pattern that can match an interval with a length of 20 which is followed by another interval which ends before 50.\n\n## Usage\n\nFirst, import the module:\n\n```js\nconst IntervalMatch = require('interval-match').IntervalMatch  // CommonJS / Node style\n// or:\nimport { IntervalMatch } from 'interval-match'  // ES6 style\n```\nThen you can call the `match` function over some intervals to know if they match a specific pattern.\n\nExample:\n\n```js\nimport { IntervalMatch } from 'interval-match'\n\n// Here we define the pattern we want to match.\n// In this case, we're saying we want to match the intervals which:\n//  - start between 35 and 45\n//  - have a length of 5 or more\n//  - are followed by a space (the gap before the next interval) which:\n//     - is half the size of them\n//  - and then by an interval which:\n//     - is smaller or equal to 30\nconst pattern = [\n    {\n        interval: {\n            name: 'A',\n            from: { lowerBound: 35, upperBound: 45 },\n            to: null,\n            minSize: 5,\n            maxSize: Infinity\n        },\n        followingSpace: {\n            name: 'B',\n            minSize: 'A * 0.5',\n            maxSize: 'A * 0.5'\n        }\n    },\n    {\n        interval: {\n            name: 'C',\n            from: null,\n            to: null,\n            minSize: 0,\n            maxSize: 30\n        },\n        followingSpace: null\n    }\n]\n\n// Our intervals\nconst intervals = [\n    { from: 20, to: 30, data: 'apple' },\n    { from: 40, to: 60, data: 'orange' },\n    { from: 70, to: 100, data: 'lemon' }\n];\n\n// Get the matches\nconst matches = IntervalMatch.match(pattern, intervals);\n\n// Now `matches` will be:\n//   {\n//     success: true,\n//     groups:\n//      Map {\n//        'A' =\u003e { from: 40, to: 60, data: 'orange' },\n//        'B' =\u003e { from: 60, to: 70, data: undefined, isSpace: true },\n//        'C' =\u003e { from: 70, to: 100, data: 'lemon' } },\n//     result:\n//      [ { from: 40, to: 60, data: 'orange' },\n//        { from: 60, to: 70, data: undefined, isSpace: true },\n//        { from: 70, to: 100, data: 'lemon' } ]\n//   }\n```\n\n## Patterns\n\nAs we saw in the example, a pattern is actually an array of rules, each of which is focused on a single interval. So, a sequence of rules describes how the succession of the intervals should look like.\n\nThere are two types of rules: *IntervalRule* and *SpaceRule*. The first is applied to intervals, the second to the gaps between intervals.\n\n### IntervalRule\n\n```js\n{\n    name: 'A',\n    from: { lowerBound: 35, upperBound: 45 },\n    to: null,\n    minSize: 5,\n    maxSize: Infinity\n}\n```\n\n* **name:** string\n\n   The name to assign to the matched interval to identify it in the result. If it is in the form of an identifier (only letters, numbers and underscores, and doesn't start with a number) then it can be used in expressions (see below).\n   \n* **from:** Endpoint | null\n\n   If not null, defines where the interval should start. It takes an Endpoint, which is an object like the following, that you can use to specify the allowed range for the start of the interval:\n   \n   ```js\n   { lowerBound: number, upperBound: number }\n   ```\n\n* **to:** Endpoint | null\n\n   If not null, defines where the interval should end. See **from**.\n\n* **minSize:** number | string\n\n   Defines the minimum size of the interval. If it is a string, the value is interpreted as an arithmetic expression which:\n     * can use `+`, `-` and `*` operators (no division)\n     * can use any preceding matched name as a variable (e.g: `1.5 * (A + B) - 1`)\n     * must be *linear*, in a mathematical sense\n\n* **maxSize:** number | string\n\n   Defines the maximum size of the interval. See **minSize**.\n\n### SpaceRule\n\n```js\n{\n    name: 'B',\n    minSize: 'A * 0.5',\n    maxSize: 100\n}\n```\n\n* **name:** string\n\n   The name to assign to the matched gap to identify it in the result. See **IntervalRule.name** for more info.\n\n* **minSize:** number | string\n\n   Defines the minimum size of the gap. See **IntervalRule.minSize** for more info.\n\n* **maxSize:** number | string\n\n   Defines the maximum size of the gap. See **IntervalRule.maxSize** for more info.\n\n\u003c!--\n## Current Limitations\nno overlapping intervals\nprecedingSpace--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieleds%2Finterval-match","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanieleds%2Finterval-match","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieleds%2Finterval-match/lists"}