New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

common-sequence

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

common-sequence - npm Package Compare versions

Comparing version
1.0.2
to
2.0.0
+49
dist/index.js
(function (factory) {
typeof define === 'function' && define.amd ? define(factory) :
factory();
}(function () { 'use strict';
/**
* Returns an array containing the initial elements which both input arrays have in common.
*
* A common use-case for this is discovering common ancestors between two file paths.
*
* ```js
* > commonSequence = require("common-sequence");
*
* > pathA = "/Users/lloyd/Documents/75lb/dmd".split("/");
* > pathB = "/Users/lloyd/Documents/75lb/array-tools".split("/");
*
* > commonSequence(pathA, pathB).join("/");
* '/Users/lloyd/Documents/75lb'
* ```
*
* or a more trivial example:
* ```js
* > a.commonSequence([ 1, 2, 3 ], [ 1, 2, 4 ])
* [ 1, 2 ]
* ```
* @module common-sequence
*/
module.exports = commonSequence;
/**
* Returns the initial elements which both input arrays have in common
* @param {Array} - first array to compare
* @param {Array} - second array to compare
* @returns {Array}
* @alias module:common-sequence
*/
function commonSequence (a, b) {
var result = [];
for (var i = 0; i < Math.min(a.length, b.length); i++) {
if (a[i] === b[i]) {
result.push(a[i]);
} else {
break
}
}
return result
}
}));
/**
* Returns an array containing the initial elements which both input arrays have in common.
*
* A common use-case for this is discovering common ancestors between two file paths.
*
* ```js
* > commonSequence = require("common-sequence");
*
* > pathA = "/Users/lloyd/Documents/75lb/dmd".split("/");
* > pathB = "/Users/lloyd/Documents/75lb/array-tools".split("/");
*
* > commonSequence(pathA, pathB).join("/");
* '/Users/lloyd/Documents/75lb'
* ```
*
* or a more trivial example:
* ```js
* > a.commonSequence([ 1, 2, 3 ], [ 1, 2, 4 ])
* [ 1, 2 ]
* ```
* @module common-sequence
*/
module.exports = commonSequence
/**
* Returns the initial elements which both input arrays have in common
* @param {Array} - first array to compare
* @param {Array} - second array to compare
* @returns {Array}
* @alias module:common-sequence
*/
function commonSequence (a, b) {
var result = []
for (var i = 0; i < Math.min(a.length, b.length); i++) {
if (a[i] === b[i]) {
result.push(a[i])
} else {
break
}
}
return result
}
[![view on npm](http://img.shields.io/npm/v/common-sequence.svg)](https://www.npmjs.org/package/common-sequence)
[![npm module downloads per month](http://img.shields.io/npm/dt/common-sequence.svg)](https://www.npmjs.org/package/common-sequence)
[![Build Status](https://travis-ci.org/75lb/common-sequence.svg?branch=master)](https://travis-ci.org/75lb/common-sequence)
[![Dependency Status](https://badgen.net/david/dep/75lb/common-sequence)](https://david-dm.org/75lb/common-sequence)
{{>main}}
### Load anywhere
This library is compatible with Node.js, the Web and any style of module loader. It can be loaded anywhere, natively without transpilation.
Node.js:
```js
const arrayify = require('common-sequence')
```
Within Node.js with ECMAScript Module support enabled:
```js
import arrayify from 'common-sequence'
```
Within an modern browser ECMAScript Module:
```js
import arrayify from './node_modules/common-sequence/index.mjs'
```
Old browser (adds `window.commonSequence`):
```html
<script nomodule src="./node_modules/common-sequence/dist/index.js"></script>
```
* * *
&copy; 2015-19 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
+1
-1
The MIT License (MIT)
Copyright (c) 2015 Lloyd Brookes <75pound@gmail.com>
Copyright (c) 2015-19 Lloyd Brookes <75pound@gmail.com>

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "common-sequence",
"author": "Lloyd Brookes <75pound@gmail.com>",
"version": "1.0.2",
"version": "2.0.0",
"description": "Returns an array containing the initial elements which both input arrays have in common",
"repository": "https://github.com/75lb/common-sequence.git",
"repository": "https://github.com/75lb/common-sequence",
"license": "MIT",
"main": "./lib/common-sequence.js",
"main": "dist/index.js",
"module": "index.mjs",
"keywords": [

@@ -20,13 +21,18 @@ "common",

"engines": {
"node": ">=0.10.0"
"node": ">=8"
},
"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"
"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": "^1.1.1",
"tape": "^4.0.0"
}
"jsdoc-to-markdown": "^5.0.1",
"rollup": "^1.21.4",
"test-runner": "^0.6.0"
},
"files": [
"index.mjs",
"dist/index.js"
]
}
[![view on npm](http://img.shields.io/npm/v/common-sequence.svg)](https://www.npmjs.org/package/common-sequence)
[![npm module downloads per month](http://img.shields.io/npm/dm/common-sequence.svg)](https://www.npmjs.org/package/common-sequence)
[![npm module downloads per month](http://img.shields.io/npm/dt/common-sequence.svg)](https://www.npmjs.org/package/common-sequence)
[![Build Status](https://travis-ci.org/75lb/common-sequence.svg?branch=master)](https://travis-ci.org/75lb/common-sequence)
[![Dependency Status](https://david-dm.org/75lb/common-sequence.svg)](https://david-dm.org/75lb/common-sequence)
[![Dependency Status](https://badgen.net/david/dep/75lb/common-sequence)](https://david-dm.org/75lb/common-sequence)
<a name="module_common-sequence"></a>
## common-sequence
Returns an array containing the initial elements which both input arrays have in common.
A common use-case for this is discovering common ancestors between two file paths.
A common use-case for this is discovering common ancestors between two file paths.

@@ -29,2 +30,3 @@ ```js

<a name="exp_module_common-sequence--commonSequence"></a>
### commonSequence(a, b) ⇒ <code>Array</code> ⏏

@@ -41,4 +43,32 @@ Returns the initial elements which both input arrays have in common

### Load anywhere
This library is compatible with Node.js, the Web and any style of module loader. It can be loaded anywhere, natively without transpilation.
Node.js:
```js
const arrayify = require('common-sequence')
```
Within Node.js with ECMAScript Module support enabled:
```js
import arrayify from 'common-sequence'
```
Within an modern browser ECMAScript Module:
```js
import arrayify from './node_modules/common-sequence/index.mjs'
```
Old browser (adds `window.commonSequence`):
```html
<script nomodule src="./node_modules/common-sequence/dist/index.js"></script>
```
* * *
&copy; 2015 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
&copy; 2015-19 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
{
"bitwise": true,
"camelcase": true,
"eqeqeq": true,
"globals": { "describe" : false, "it": false, "beforeEach": false },
"globalstrict": false,
"indent": 4,
"laxbreak": true,
"maxparams": 3,
"multistr": true,
"newcap": true,
"node": true,
"quotmark": "double",
"trailing": true,
"undef": true,
"unused": true
}

Sorry, the diff of this file is not supported yet

language: node_js
node_js:
- '0.12'
- '0.11'
- '0.10'
- 'iojs'
[![view on npm](http://img.shields.io/npm/v/common-sequence.svg)](https://www.npmjs.org/package/common-sequence)
[![npm module downloads per month](http://img.shields.io/npm/dm/common-sequence.svg)](https://www.npmjs.org/package/common-sequence)
[![Build Status](https://travis-ci.org/75lb/common-sequence.svg?branch=master)](https://travis-ci.org/75lb/common-sequence)
[![Dependency Status](https://david-dm.org/75lb/common-sequence.svg)](https://david-dm.org/75lb/common-sequence)
{{>main}}
* * *
&copy; 2015 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
"use strict";
/**
Returns an array containing the initial elements which both input arrays have in common.
A common use-case for this is discovering common ancestors between two file paths.
```js
> commonSequence = require("common-sequence");
> pathA = "/Users/lloyd/Documents/75lb/dmd".split("/");
> pathB = "/Users/lloyd/Documents/75lb/array-tools".split("/");
> commonSequence(pathA, pathB).join("/");
'/Users/lloyd/Documents/75lb'
```
or a more trivial example:
```js
> a.commonSequence([ 1, 2, 3 ], [ 1, 2, 4 ])
[ 1, 2 ]
```
@module common-sequence
*/
module.exports = commonSequence;
/**
Returns the initial elements which both input arrays have in common
@param {Array} - first array to compare
@param {Array} - second array to compare
@returns {Array}
@alias module:common-sequence
*/
function commonSequence(a, b){
var result = [];
for (var i = 0; i < Math.min(a.length, b.length); i++){
if (a[i] === b[i]){
result.push(a[i]);
} else {
break;
}
}
return result;
}
"use strict";
var test = require("tape");
var commonSequence = require("../");
test(".commonSequence()", function(t){
var arr1 = [ 1,2,3,4 ];
var arr2 = [ 1,2,4,5 ];
var expected = [ 1, 2 ];
var result = commonSequence(arr1, arr2);
t.deepEqual(result, expected);
t.end();
});
test(".commonSequence() 2", function(t){
var arr1 = [ 1,2,3,4 ];
var arr2 = [ 0,2,3,4 ];
var expected = [ ];
var result = commonSequence(arr1, arr2);
t.deepEqual(result, expected);
t.end();
});