Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,50 @@
# Array Flatten
[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
> Flatten nested arrays.
## Installation
```
npm install array-flatten --save
```
## Usage
```javascript
var flatten = require('array-flatten')
flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
flatten.depth([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
(function () {
flatten.from(arguments) //=> [1, 2, 3]
})(1, [2, 3])
```
### Methods
* **flatten(array)** Flatten a nested array structure
* **flatten.from(arrayish)** Flatten an array-like structure (E.g. arguments)
* **flatten.depth(array, depth)** Flatten a nested array structure with a specific depth
* **flatten.fromDepth(arrayish, depth)** Flatten an array-like structure with a specific depth
## License
MIT
[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
[npm-url]: https://npmjs.org/package/array-flatten
[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
[downloads-url]: https://npmjs.org/package/array-flatten
[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master

View File

@@ -0,0 +1,16 @@
declare function flatten <T> (array: flatten.NestedArray<T>): T[];
declare namespace flatten {
export interface NestedArray <T> extends Array<T | NestedArray<T>> {}
export interface NestedList <T> {
[index: number]: T | NestedList<T>;
length: number;
}
export function from <T> (array: NestedList<T>): T[];
export function depth <T> (array: NestedArray<T>, depth: number): NestedArray<T>;
export function depthFrom <T> (array: NestedList<T>, depth: number): NestedArray<T>;
}
export = flatten;

View File

@@ -0,0 +1,108 @@
'use strict'
/**
* Expose `arrayFlatten`.
*/
module.exports = flatten
module.exports.from = flattenFrom
module.exports.depth = flattenDepth
module.exports.fromDepth = flattenFromDepth
/**
* Flatten an array.
*
* @param {Array} array
* @return {Array}
*/
function flatten (array) {
if (!Array.isArray(array)) {
throw new TypeError('Expected value to be an array')
}
return flattenFrom(array)
}
/**
* Flatten an array-like structure.
*
* @param {Array} array
* @return {Array}
*/
function flattenFrom (array) {
return flattenDown(array, [])
}
/**
* Flatten an array-like structure with depth.
*
* @param {Array} array
* @param {number} depth
* @return {Array}
*/
function flattenDepth (array, depth) {
if (!Array.isArray(array)) {
throw new TypeError('Expected value to be an array')
}
return flattenFromDepth(array, depth)
}
/**
* Flatten an array-like structure with depth.
*
* @param {Array} array
* @param {number} depth
* @return {Array}
*/
function flattenFromDepth (array, depth) {
if (typeof depth !== 'number') {
throw new TypeError('Expected the depth to be a number')
}
return flattenDownDepth(array, [], depth)
}
/**
* Flatten an array indefinitely.
*
* @param {Array} array
* @param {Array} result
* @return {Array}
*/
function flattenDown (array, result) {
for (var i = 0; i < array.length; i++) {
var value = array[i]
if (Array.isArray(value)) {
flattenDown(value, result)
} else {
result.push(value)
}
}
return result
}
/**
* Flatten an array with depth.
*
* @param {Array} array
* @param {Array} result
* @param {number} depth
* @return {Array}
*/
function flattenDownDepth (array, result, depth) {
depth--
for (var i = 0; i < array.length; i++) {
var value = array[i]
if (depth > -1 && Array.isArray(value)) {
flattenDownDepth(value, result, depth)
} else {
result.push(value)
}
}
return result
}

View File

@@ -0,0 +1,75 @@
{
"_args": [
[
"array-flatten@2.1.1",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "array-flatten@2.1.1",
"_id": "array-flatten@2.1.1",
"_inBundle": false,
"_integrity": "sha1-Qmu52oQJDBg42BLIFQryCoMx4pY=",
"_location": "/react-scripts/array-flatten",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "array-flatten@2.1.1",
"name": "array-flatten",
"escapedName": "array-flatten",
"rawSpec": "2.1.1",
"saveSpec": null,
"fetchSpec": "2.1.1"
},
"_requiredBy": [
"/react-scripts/bonjour"
],
"_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-2.1.1.tgz",
"_spec": "2.1.1",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": {
"name": "Blake Embrey",
"email": "hello@blakeembrey.com",
"url": "http://blakeembrey.me"
},
"bugs": {
"url": "https://github.com/blakeembrey/array-flatten/issues"
},
"description": "Flatten nested arrays",
"devDependencies": {
"benchmarked": "^0.2.5",
"istanbul": "^0.4.0",
"mocha": "^3.1.2",
"standard": "^8.5.0"
},
"files": [
"array-flatten.js",
"array-flatten.d.ts",
"LICENSE"
],
"homepage": "https://github.com/blakeembrey/array-flatten",
"keywords": [
"array",
"flatten",
"arguments",
"depth",
"fast",
"for"
],
"license": "MIT",
"main": "array-flatten.js",
"name": "array-flatten",
"repository": {
"type": "git",
"url": "git://github.com/blakeembrey/array-flatten.git"
},
"scripts": {
"benchmark": "node benchmark",
"lint": "standard",
"test": "npm run lint && npm run test-cov",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- -R spec --bail",
"test-spec": "mocha -R spec --bail"
},
"typings": "array-flatten.d.ts",
"version": "2.1.1"
}