diff options
Diffstat (limited to 'node_modules/clean-yaml-object')
-rw-r--r-- | node_modules/clean-yaml-object/index.js | 92 | ||||
-rw-r--r-- | node_modules/clean-yaml-object/license | 23 | ||||
-rw-r--r-- | node_modules/clean-yaml-object/package.json | 37 | ||||
-rw-r--r-- | node_modules/clean-yaml-object/readme.md | 52 |
4 files changed, 0 insertions, 204 deletions
diff --git a/node_modules/clean-yaml-object/index.js b/node_modules/clean-yaml-object/index.js deleted file mode 100644 index 77b08168e..000000000 --- a/node_modules/clean-yaml-object/index.js +++ /dev/null @@ -1,92 +0,0 @@ -'use strict'; -module.exports = function (object, filterFn) { - return cleanYamlObj(object, filterFn || defaultFilter, true, []); -}; - -function cleanYamlObj(object, filter, isRoot, seen) { - if (object === undefined) { - return null; - } - - if (typeof object === 'function') { - return object.toString(); - } - - if (Buffer.isBuffer(object)) { - return 'Buffer\n' + object.toString('hex').split('') - .reduce(function (set, c) { - if (set.length && set[set.length - 1].length === 1) { - set[set.length - 1] += c; - if (set.length && set.length % 20 === 0) { - set[set.length - 1] += '\n'; - } else { - set[set.length - 1] += ' '; - } - } else { - set.push(c); - } - return set; - }, []).join('').trim(); - } - - if (object && typeof object === 'object') { - if (object instanceof RegExp) { - return object.toString(); - } - - seen = seen.concat([object]); - - var isArray = Array.isArray(object); - - // Fill in any holes. This means we lose expandos, - // but we were gonna lose those anyway. - if (isArray) { - object = Array.apply(null, object); - } - - var isError = object && typeof object === 'object' && object instanceof Error; - - var set = isArray ? [] : {}; - - // name is typically not an ownProperty on an Error - if (isError && object.name && !object.hasOwnProperty('name') && filter('name', isRoot, object, set)) { - setProp('name', object, set, seen, filter); - } - - var keys = Object.getOwnPropertyNames(object); - return keys.reduce(function (set, k) { - // magic property! - if (isArray && k === 'length') { - return set; - } - - // Don't dump massive EventEmitter and Domain - // objects onto the output, that's never friendly. - if (isError && /^domain/.test(k)) { - return set; - } - - if (!filter(k, isRoot, object, set)) { - return set; - } - - setProp(k, object, set, seen, filter); - - return set; - }, set); - } - - return object; -} - -function setProp(propName, source, target, seen, filter) { - if (seen.indexOf(source[propName]) === -1) { - target[propName] = cleanYamlObj(source[propName], filter, false, seen); - } else { - target[propName] = '[Circular]'; - } -} - -function defaultFilter() { - return true; -} diff --git a/node_modules/clean-yaml-object/license b/node_modules/clean-yaml-object/license deleted file mode 100644 index 8dc0833d1..000000000 --- a/node_modules/clean-yaml-object/license +++ /dev/null @@ -1,23 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Isaac Z. Schlueter <i@izs.me>, James Talmage <james@talmage.io> (github.com/jamestalmage), and Contributors - -Extracted from code in node-tap http://www.node-tap.org/ - -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. diff --git a/node_modules/clean-yaml-object/package.json b/node_modules/clean-yaml-object/package.json deleted file mode 100644 index 98305ac56..000000000 --- a/node_modules/clean-yaml-object/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "clean-yaml-object", - "version": "0.1.0", - "description": "Clean up an object prior to serialization", - "license": "MIT", - "repository": "tapjs/clean-yaml-object", - "author": { - "name": "James Talmage", - "email": "james@talmage.io", - "url": "github.com/jamestalmage" - }, - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "xo && nyc --cache --reporter=lcov --reporter=text ava" - }, - "files": [ - "index.js" - ], - "keywords": [ - "serialize", - "clean", - "dedupe", - "circular", - "yaml", - "json", - "error" - ], - "dependencies": {}, - "devDependencies": { - "ava": "^0.10.0", - "coveralls": "^2.11.6", - "nyc": "^5.3.0", - "xo": "^0.12.1" - } -} diff --git a/node_modules/clean-yaml-object/readme.md b/node_modules/clean-yaml-object/readme.md deleted file mode 100644 index 4e4e5a67b..000000000 --- a/node_modules/clean-yaml-object/readme.md +++ /dev/null @@ -1,52 +0,0 @@ -# clean-yaml-object [](https://travis-ci.org/tapjs/clean-yaml-object) [](https://coveralls.io/github/tapjs/clean-yaml-object?branch=master) - -> Clean up an object prior to serialization. - -Replaces circular references, pretty prints Buffers, and numerous other enhancements. Primarily designed to prepare Errors for serialization to JSON/YAML. - -Extracted from [`node-tap`](https://github.com/tapjs/node-tap) - -## Install - -``` -$ npm install --save clean-yaml-object -``` - - -## Usage - -```js -const cleanYamlObject = require('clean-yaml-object'); - -cleanYamlObject(new Error('foo')); -//=> {name: 'Error', message: 'foo', stack: ...} -``` - - -## API - -### cleanYamlObject(input, [filterFn]) - -Returns a deep copy of `input` that is suitable for serialization. - -#### input - -Type: `*` - -Any object. - -#### filterFn - -Type: `callback(propertyName, isRoot, source, target)` - -Optional filter callback. Returning `true` will cause the property to be copied. Otherwise it will be skipped - -- `propertyName`: The property being copied. -- `isRoot`: `true` only if `source` is the top level object passed to `copyYamlObject` -- `source`: The source from which `source[propertyName]` will be copied. -- `target`: The target object. - -## License - - -MIT © [Isaac Z. Schlueter](http://github.com/isaacs) [James Talmage](http://github.com/jamestalmage) |