{"name":"common-sequence","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"3.0.0","description":"Returns an array containing the initial elements which both input arrays have in common","repository":{"type":"git","url":"git+https://github.com/75lb/common-sequence.git"},"license":"MIT","type":"module","exports":{"import":"./index.js","require":"./dist/index.cjs"},"keywords":["common","path","folder","dir","compare","parent","array","sequence"],"engines":{"node":">=12.17"},"scripts":{"test":"75lb-nature test-runner test.js","docs":"75lb-nature jsdoc2md -t README.hbs index.js > README.md","dist":"75lb-nature cjs-build index.js"},"devDependencies":{},"_id":"common-sequence@3.0.0","gitHead":"0d1db744303d3aa6387001acd465dc7cdc2eb17f","bugs":{"url":"https://github.com/75lb/common-sequence/issues"},"homepage":"https://github.com/75lb/common-sequence#readme","_nodeVersion":"22.8.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-g/CgSYk93y+a1IKm50tKl7kaT/OjjTYVQlEbUlt/49ZLV1mcKpUU7iyDiqTAeLdb4QDtQfq3ako8y8v//fzrWQ==","shasum":"d631cf0306fb2dea97e1d6669a1627950803fca1","tarball":"http://registry-npm.ywwl.com/common-sequence/download/common-sequence-3.0.0.tgz","fileCount":6,"unpackedSize":7897,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID+sFrfHtAuPzNLzp9tOqjRNErvYni9apyErZf1qdlZKAiEAhAwbUNrG3hSkE/0PO4ddX4QlgUZ/ETQvofuRn51E2WI="}],"size":2359,"noattachment":false,"key":"/common-sequence/-/common-sequence-3.0.0.tgz"},"_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/common-sequence_3.0.0_1725628972070_0.9282978035620797"},"_hasShrinkwrap":false,"readme":"[![view on npm](https://badgen.net/npm/v/common-sequence)](https://www.npmjs.org/package/common-sequence)\n[![npm module downloads](https://badgen.net/npm/dt/common-sequence)](https://www.npmjs.org/package/common-sequence)\n[![Gihub repo dependents](https://badgen.net/github/dependents-repo/75lb/common-sequence)](https://github.com/75lb/common-sequence/network/dependents?dependent_type=REPOSITORY)\n[![Gihub package dependents](https://badgen.net/github/dependents-pkg/75lb/common-sequence)](https://github.com/75lb/common-sequence/network/dependents?dependent_type=PACKAGE)\n[![Node.js CI](https://github.com/75lb/common-sequence/actions/workflows/node.js.yml/badge.svg)](https://github.com/75lb/common-sequence/actions/workflows/node.js.yml)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)\n\n<a name=\"module_common-sequence\"></a>\n\n## common-sequence\nReturns an array containing the initial elements which both input arrays have in common.\n\nA common use-case for this is discovering common ancestors between two file paths.\n\n```js\n> commonSequence = require('common-sequence');\n\n> pathA = '/Users/lloyd/Documents/75lb/dmd'.split('/');\n> pathB = '/Users/lloyd/Documents/75lb/array-tools'.split('/');\n\n> commonSequence(pathA, pathB).join('/');\n'/Users/lloyd/Documents/75lb'\n```\n\nor a more trivial example:\n```js\n> a.commonSequence([ 1, 2, 3 ], [ 1, 2, 4 ])\n[ 1, 2 ]\n```\n\n<a name=\"exp_module_common-sequence--commonSequence\"></a>\n\n### commonSequence(a, b) ⇒ <code>Array</code> ⏏\nReturns the initial elements which both input arrays have in common\n\n**Kind**: Exported function  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| a | <code>Array</code> | first array to compare |\n| b | <code>Array</code> | second array to compare |\n\n\n### Load anywhere\n\nThis library is compatible with Node.js and the Web. It can be loaded anywhere, natively without transpilation.\n\nNode.js CommonJS:\n\n```js\nconst commonSequence = require('common-sequence')\n```\n\nNode.js ECMAScript Module:\n\n```js\nimport commonSequence from 'common-sequence'\n```\n\nWithin an modern browser ECMAScript Module:\n\n```js\nimport commonSequence from './node_modules/common-sequence/index.js'\n```\n\n* * *\n\n&copy; 2015-25 Lloyd Brookes \\<75pound@gmail.com\\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).\n","publish_time":1725628972198,"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"_cnpm_publish_time":1725628972198,"dist-tags":{"latest":"3.0.0"}}