Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dance2die/subsequence
simple NPM package to check for a subsequence in an array. (Don't use it yet)
https://github.com/dance2die/subsequence
npm subsquence typescript
Last synced: about 2 months ago
JSON representation
simple NPM package to check for a subsequence in an array. (Don't use it yet)
- Host: GitHub
- URL: https://github.com/dance2die/subsequence
- Owner: dance2die
- License: mit
- Created: 2021-01-09T22:11:48.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-12T05:38:44.000Z (about 4 years ago)
- Last Synced: 2024-04-26T19:03:34.063Z (9 months ago)
- Topics: npm, subsquence, typescript
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@sung/subsequence
- Size: 112 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Subsequence
An NPM package for checking if an array is a [subsequence](https://en.wikipedia.org/wiki/Subsequence) of another array.
# Usage
```js
const subsequence = require('@dance2die/subsequence');const input = [5, 1, 22, 25, 6, -1, 8, 10];
const sequence = [1, 6, -1, 10];const isSubsequence = subsequence.validate(sequence, input)
console.info(isSubsequence);
// prints "true"// You can validate a Common Subsequence of X and Y
// https://en.wikipedia.org/wiki/Subsequence#Common_subsequence
const x = ['a', 'c', 'b', 'd', 'e', 'g', 'c', 'e', 'd', 'b', 'g'];
const y = ['b', 'e', 'g', 'c', 'f', 'e', 'u', 'b', 'k'];
const z = ['b', 'e', 'e' ]const isCommonSubsequence = subsequence.validate(z, x, y)
```