Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flatten-list

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatten-list - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

LICENSE

28

index.js

@@ -0,3 +1,27 @@

var isList;
if (typeof window !== 'undefined') {
// Running in a browser
isList = (function(window, Node) {
return function(value) {
return (
value &&
typeof value === 'object' &&
typeof value.length === 'number' &&
!(value instanceof Node) &&
value !== window);
}
})(window, window.Node);
} else {
// Running in non-browser environment
isList = function(value) {
return (
value &&
typeof value === 'object' &&
typeof value.length === 'number');
};
}
function add(array, value) {
if (typeof value.length === 'number') {
if (isList(value)) {
for (var i = 0; i < value.length; i++) {

@@ -17,2 +41,2 @@ add(array, value[i]);

module.exports = flatten;
module.exports = flatten;

6

package.json
{
"name": "flatten-list",
"version": "0.0.1",
"version": "0.0.2",
"description": "Flatten an array or array-like objects",
"main": "index.js",
"scripts": {
"test": "tap test.js"
"test": "tape test.js"
},

@@ -26,4 +26,4 @@ "repository": {

"devDependencies": {
"tap": "~0.4.4"
"tape": "~1.1.1"
}
}
# flatten-list
[![Build Status](https://travis-ci.org/conradz/flatten-list.png)](https://travis-ci.org/conradz/flatten-list)
[![NPM](https://nodei.co/npm/flatten-list.png?compact=true)](https://nodei.co/npm/flatten-list/)
[![Build Status](https://drone.io/github.com/conradz/flatten-list/status.png)](https://drone.io/github.com/conradz/flatten-list/latest)
[![Dependency Status](https://gemnasium.com/conradz/flatten-list.png)](https://gemnasium.com/conradz/flatten-list)

@@ -5,0 +7,0 @@

@@ -1,2 +0,2 @@

var test = require('tap').test,
var test = require('tape'),
flatten = require('./');

@@ -41,2 +41,32 @@

t.end();
});
});
test('do not convert string to array', function(t) {
var value = 'foo';
t.deepEqual(flatten(value), [value]);
t.end();
});
test('allow falsy values', function(t) {
t.deepEqual(flatten(null), [null]);
t.deepEqual(flatten(false), [false]);
t.deepEqual(flatten(undefined), [undefined]);
t.deepEqual(flatten(''), ['']);
t.end();
});
if (typeof window !== 'undefined') {
// In a browser
test('do not convert elements to array', function(t) {
var value = document.createElement('form');
t.deepEqual(flatten(value), [value]);
t.end();
});
test('do not convert window to array', function(t) {
t.deepEqual(flatten(window), [window]);
t.end();
});
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc