{"_id":"common-sequence","_rev":"4583707","name":"common-sequence","description":"Returns an array containing the initial elements which both input arrays have in common","dist-tags":{"latest":"3.0.0"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"time":{"modified":"2026-04-10T16:23:52.000Z","created":"2015-06-22T19:37:57.207Z","3.0.0":"2024-09-06T13:22:52.198Z","2.0.2":"2021-03-13T22:16:51.567Z","2.0.1":"2021-03-13T22:14:56.810Z","2.0.0":"2019-09-28T19:27:48.076Z","1.0.2":"2015-06-22T19:48:07.842Z","1.0.1":"2015-06-22T19:45:42.244Z","1.0.0":"2015-06-22T19:41:51.322Z","0.0.0":"2015-06-22T19:37:57.207Z"},"users":{"rocket0191":true},"author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/75lb/common-sequence.git"},"versions":{"3.0.0":{"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":{"shasum":"d631cf0306fb2dea97e1d6669a1627950803fca1","size":2359,"noattachment":false,"key":"/common-sequence/-/common-sequence-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/common-sequence/download/common-sequence-3.0.0.tgz"},"_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"directories":{},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/common-sequence_3.0.0_1725628972070_0.9282978035620797"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-09-06T13:22:52.198Z","publish_time":1725628972198,"_source_registry_name":"default","_cnpm_publish_time":1725628972198},"2.0.2":{"name":"common-sequence","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"2.0.2","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","main":"dist/index.js","module":"index.mjs","keywords":["common","path","folder","dir","compare","parent","array","sequence"],"engines":{"node":">=8"},"scripts":{"test":"test-runner test.js","docs":"jsdoc2md -c jsdoc.conf -t README.hbs index.mjs > README.md","dist":"rollup -f umd -n commonSequence -o dist/index.js index.mjs"},"devDependencies":{"jsdoc-to-markdown":"^7.0.0","rollup":"^2.41.2","test-runner":"^0.6.3"},"gitHead":"658a3d0557cc3f98aa7ac0e2309b697ccf387619","bugs":{"url":"https://github.com/75lb/common-sequence/issues"},"homepage":"https://github.com/75lb/common-sequence#readme","_id":"common-sequence@2.0.2","_nodeVersion":"15.11.0","_npmVersion":"7.6.0","dist":{"shasum":"accc76bdc5876a1fcd92b73484d4285fff99d838","size":2652,"noattachment":false,"key":"/common-sequence/-/common-sequence-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/common-sequence/download/common-sequence-2.0.2.tgz"},"_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"directories":{},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/common-sequence_2.0.2_1615673811360_0.5091201632017037"},"_hasShrinkwrap":false,"publish_time":1615673811567,"_cnpm_publish_time":1615673811567},"2.0.1":{"name":"common-sequence","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"2.0.1","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","main":"dist/index.js","module":"index.mjs","keywords":["common","path","folder","dir","compare","parent","array","sequence"],"engines":{"node":">=8"},"scripts":{"test":"npm run dist && test-runner test.js","docs":"jsdoc2md -c jsdoc.conf -t README.hbs index.mjs > README.md","dist":"rollup -f umd -n commonSequence -o dist/index.js index.mjs"},"devDependencies":{"jsdoc-to-markdown":"^7.0.0","rollup":"^2.41.2","test-runner":"^0.6.3"},"gitHead":"983fd63df17fbcea5a499b6f0b4a02280065c649","bugs":{"url":"https://github.com/75lb/common-sequence/issues"},"homepage":"https://github.com/75lb/common-sequence#readme","_id":"common-sequence@2.0.1","_nodeVersion":"15.11.0","_npmVersion":"7.6.0","dist":{"shasum":"5f2235f98895af75a9a4e2542271ac6037666573","size":2661,"noattachment":false,"key":"/common-sequence/-/common-sequence-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/common-sequence/download/common-sequence-2.0.1.tgz"},"_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"directories":{},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/common-sequence_2.0.1_1615673696670_0.6289296568600631"},"_hasShrinkwrap":false,"publish_time":1615673696810,"_cnpm_publish_time":1615673696810},"2.0.0":{"name":"common-sequence","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"2.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","main":"dist/index.js","module":"index.mjs","keywords":["common","path","folder","dir","compare","parent","array","sequence"],"engines":{"node":">=8"},"scripts":{"test":"npm run dist && test-runner test.js","docs":"jsdoc2md -c jsdoc.conf -t README.hbs index.mjs > README.md","dist":"rollup -f umd -n commonSequence -o dist/index.js index.mjs"},"devDependencies":{"jsdoc-to-markdown":"^5.0.1","rollup":"^1.21.4","test-runner":"^0.6.0"},"gitHead":"b55f198afcf6a09eb83de89407796b993bd6aa8b","bugs":{"url":"https://github.com/75lb/common-sequence/issues"},"homepage":"https://github.com/75lb/common-sequence#readme","_id":"common-sequence@2.0.0","_nodeVersion":"12.10.0","_npmVersion":"6.11.3","dist":{"shasum":"a4f01aaf5aebd0ac1ce43653e8c8fe6f0ef3a987","size":2578,"noattachment":false,"key":"/common-sequence/-/common-sequence-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/common-sequence/download/common-sequence-2.0.0.tgz"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/common-sequence_2.0.0_1569698867946_0.38371915046787564"},"_hasShrinkwrap":false,"publish_time":1569698868076,"_cnpm_publish_time":1569698868076},"1.0.2":{"name":"common-sequence","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"1.0.2","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","main":"./lib/common-sequence.js","keywords":["common","path","folder","dir","compare","parent","array","sequence"],"engines":{"node":">=0.10.0"},"scripts":{"test":"tape test/*.js","lint":"jshint lib/*.js bin/*.js test/*.js; echo","docs":"jsdoc2md -t jsdoc2md/README.hbs lib/*.js > README.md; echo"},"devDependencies":{"jsdoc-to-markdown":"^1.1.1","tape":"^4.0.0"},"gitHead":"bdfd45b1358fd8fc8f90c90dde9960cc9555fb01","bugs":{"url":"https://github.com/75lb/common-sequence/issues"},"homepage":"https://github.com/75lb/common-sequence#readme","_id":"common-sequence@1.0.2","_shasum":"30e07f3f8f6f7f9b3dee854f20b2d39eee086de8","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"dist":{"shasum":"30e07f3f8f6f7f9b3dee854f20b2d39eee086de8","size":2490,"noattachment":false,"key":"/common-sequence/-/common-sequence-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/common-sequence/download/common-sequence-1.0.2.tgz"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"directories":{},"publish_time":1435002487842,"_cnpm_publish_time":1435002487842,"_hasShrinkwrap":false},"1.0.1":{"name":"common-sequence","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"1.0.1","description":"common-sequence","repository":{"type":"git","url":"git+https://github.com/75lb/common-sequence.git"},"license":"MIT","main":"./lib/common-sequence.js","keywords":["common","path","folder","dir","compare","parent","array","sequence"],"engines":{"node":">=0.10.0"},"scripts":{"test":"tape test/*.js","lint":"jshint lib/*.js bin/*.js test/*.js; echo","docs":"jsdoc2md -t jsdoc2md/README.hbs lib/*.js > README.md; echo"},"devDependencies":{"jsdoc-to-markdown":"^1.1.1","tape":"^4.0.0"},"gitHead":"7a20e064663bc02aff788000f81eb60414172bce","bugs":{"url":"https://github.com/75lb/common-sequence/issues"},"homepage":"https://github.com/75lb/common-sequence#readme","_id":"common-sequence@1.0.1","_shasum":"2ea04175c819a8084699638f75bbd4de8a396fec","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"dist":{"shasum":"2ea04175c819a8084699638f75bbd4de8a396fec","size":2488,"noattachment":false,"key":"/common-sequence/-/common-sequence-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/common-sequence/download/common-sequence-1.0.1.tgz"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"directories":{},"publish_time":1435002342244,"_cnpm_publish_time":1435002342244,"_hasShrinkwrap":false},"1.0.0":{"name":"common-sequence","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"1.0.0","description":"common-sequence","repository":{"type":"git","url":"git+https://github.com/75lb/common-sequence.git"},"license":"MIT","main":"./lib/common-sequence.js","keywords":[],"engines":{"node":">=0.10.0"},"scripts":{"test":"tape test/*.js","lint":"jshint lib/*.js bin/*.js test/*.js; echo","docs":"jsdoc2md -t jsdoc2md/README.hbs lib/*.js > README.md; echo"},"devDependencies":{"jsdoc-to-markdown":"^1.1.1","tape":"^4.0.0"},"gitHead":"d14e02bc154444c9af78b6223438d85ce0e4f306","bugs":{"url":"https://github.com/75lb/common-sequence/issues"},"homepage":"https://github.com/75lb/common-sequence#readme","_id":"common-sequence@1.0.0","_shasum":"782c66b86e788a2e89301bfd90a51a350474a7a1","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"dist":{"shasum":"782c66b86e788a2e89301bfd90a51a350474a7a1","size":2451,"noattachment":false,"key":"/common-sequence/-/common-sequence-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/common-sequence/download/common-sequence-1.0.0.tgz"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"directories":{},"publish_time":1435002111322,"_cnpm_publish_time":1435002111322,"_hasShrinkwrap":false},"0.0.0":{"name":"common-sequence","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"0.0.0","description":"common-sequence","repository":{"type":"git","url":"git+https://github.com/75lb/common-sequence.git"},"license":"MIT","main":"./lib/common-sequence.js","keywords":[],"engines":{"node":">=0.10.0"},"scripts":{"test":"tape test/*.js","lint":"jshint lib/*.js bin/*.js test/*.js; echo","docs":"jsdoc2md -t jsdoc2md/README.hbs lib/*.js > README.md; echo"},"devDependencies":{"jsdoc-to-markdown":"^1.1.1","tape":"^4.0.0"},"gitHead":"8e40345374c37993fe5904e765ca5f519a08e8d2","bugs":{"url":"https://github.com/75lb/common-sequence/issues"},"homepage":"https://github.com/75lb/common-sequence#readme","_id":"common-sequence@0.0.0","_shasum":"be36fca5cc4874ec238ab8b939ac03cd1f97b632","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"dist":{"shasum":"be36fca5cc4874ec238ab8b939ac03cd1f97b632","size":2373,"noattachment":false,"key":"/common-sequence/-/common-sequence-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/common-sequence/download/common-sequence-0.0.0.tgz"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"directories":{},"publish_time":1435001877207,"_cnpm_publish_time":1435001877207,"_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","_attachments":{},"homepage":"https://github.com/75lb/common-sequence#readme","bugs":{"url":"https://github.com/75lb/common-sequence/issues"},"license":"MIT"}