aboutsummaryrefslogtreecommitdiff
path: root/node_modules/structured-clone
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/structured-clone')
-rw-r--r--node_modules/structured-clone/.npmignore2
-rw-r--r--node_modules/structured-clone/LICENSE21
-rw-r--r--node_modules/structured-clone/README.md36
-rw-r--r--node_modules/structured-clone/clone.js38
-rw-r--r--node_modules/structured-clone/index.js6
-rw-r--r--node_modules/structured-clone/package.json16
-rw-r--r--node_modules/structured-clone/serialize.js223
-rw-r--r--node_modules/structured-clone/test/test.js100
8 files changed, 0 insertions, 442 deletions
diff --git a/node_modules/structured-clone/.npmignore b/node_modules/structured-clone/.npmignore
deleted file mode 100644
index 3351ce2e9..000000000
--- a/node_modules/structured-clone/.npmignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*.log
-node_modules
diff --git a/node_modules/structured-clone/LICENSE b/node_modules/structured-clone/LICENSE
deleted file mode 100644
index fca65eaff..000000000
--- a/node_modules/structured-clone/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2014 Technical Machine, Inc.
-
-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. \ No newline at end of file
diff --git a/node_modules/structured-clone/README.md b/node_modules/structured-clone/README.md
deleted file mode 100644
index 0e70f6982..000000000
--- a/node_modules/structured-clone/README.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# structured-clone
-
-Implements the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/The_structured_clone_algorithm). Clone JSON types, RegExp, Buffers, and Dates, returning a cloned object or a buffer that can be deserialized into a structured clone
-
-```
-npm install structured-clone
-```
-
-```js
-var clone = require('structured-clone');
-```
-
-* **clone**(obj) → *Object*
-* clone.**serialize**(obj) → *Buffer*
-* clone.**deserialize**(buf) → *Object*
-
-## Encoded format
-
-The encoded format takes this form:
-
-1. A UTF-8 encoded JSON string.
-2. A null byte.
-3. A binary blob that is the concatenation of all binary buffers in the original object. There are no delimiters in this buffer, indexes are represented in the JSON value (see below).
-
-Dates, regexps, buffers, and cycles are encoded in a particular way to be decoded properly:
-
-- Dates are encoded as the string '\x10d' followed by the JSON-stringified encoding of the date.
-- Regexps are encoded as the string '\x10r{flags},{regexp source}'.
-- Buffers are encoded as the string '\x10b{start},{length}'. All buffers in the encoded value are concatenated and placed in the binary blob. The start and length parameters indicate the indexes the slice of the buffer was encoded in.
-- Lastly, string that begin with '\x10' are encoded as '\x10s{string}' to properly escape them.
-
-**Optimizations:** If only a JSON value is being encoded (i.e. no Buffer values included), the null byte can be omitted, thus making the encoded format equivalent to a JSON-encoded string. If only a buffer is being encoded, it is equivalent to a null byte followed by the buffer (i.e. the JSON string is 0-length).
-
-## License
-
-MIT \ No newline at end of file
diff --git a/node_modules/structured-clone/clone.js b/node_modules/structured-clone/clone.js
deleted file mode 100644
index df1e4884e..000000000
--- a/node_modules/structured-clone/clone.js
+++ /dev/null
@@ -1,38 +0,0 @@
-// Implement the clone algorithm directly.
-// https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/The_structured_clone_algorithm
-
-function clone (oToBeCloned, cloned, clonedpairs)
-{
- cloned = cloned || [];
- clonedpairs = clonedpairs || [];
-
- if (cloned.indexOf(oToBeCloned) > -1) {
- return clonedpairs[cloned.indexOf(oToBeCloned)];
- }
-
- if (oToBeCloned === null || !(oToBeCloned instanceof Object)) { return oToBeCloned; }
- var oClone, fConstr = oToBeCloned.constructor;
- switch (fConstr) {
- case RegExp:
- oClone = new fConstr(oToBeCloned.source, "g".substr(0, Number(oToBeCloned.global)) + "i".substr(0, Number(oToBeCloned.ignoreCase)) + "m".substr(0, Number(oToBeCloned.multiline)));
- break;
- case Date:
- oClone = new fConstr(oToBeCloned.getTime());
- break;
- // etc.
- default:
- if (Buffer.isBuffer(oToBeCloned)) {
- oClone = new Buffer(oToBeCloned.length);
- oToBeCloned.copy(oClone);
- } else if (oToBeCloned instanceof Error) {
- oClone = new Error(oToBeCloned.message);
- } else {
- oClone = new fConstr();
- cloned.push(oToBeCloned); clonedpairs.push(oClone);
- for (var sProp in oToBeCloned) { oClone[sProp] = clone(oToBeCloned[sProp], cloned, clonedpairs); }
- }
- }
- return oClone;
-}
-
-exports.clone = clone; \ No newline at end of file
diff --git a/node_modules/structured-clone/index.js b/node_modules/structured-clone/index.js
deleted file mode 100644
index 50d17f7f3..000000000
--- a/node_modules/structured-clone/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-// Public API.
-
-module.exports = require('./clone').clone;
-module.exports.clone = require('./clone').clone;
-module.exports.serialize = require('./serialize').serialize;
-module.exports.deserialize = require('./serialize').deserialize; \ No newline at end of file
diff --git a/node_modules/structured-clone/package.json b/node_modules/structured-clone/package.json
deleted file mode 100644
index cb9c8d952..000000000
--- a/node_modules/structured-clone/package.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "name": "structured-clone",
- "version": "0.2.2",
- "repository": "tessel/structured-clone",
- "description": "Implements the structured clone algorithm. Clone JSON types, RegExp, Buffers, and Dates, returning a cloned object or a buffer that can be deserialized into a structured clone.",
- "main": "index.js",
- "scripts": {
- "test": "node_modules/.bin/tap test/*.js"
- },
- "author": "Tim Cameron Ryan <tim@technical.io>",
- "license": "MIT",
- "devDependencies": {
- "tap": "~0.4.8",
- "tape": "~2.10.2"
- }
-}
diff --git a/node_modules/structured-clone/serialize.js b/node_modules/structured-clone/serialize.js
deleted file mode 100644
index 44c984f38..000000000
--- a/node_modules/structured-clone/serialize.js
+++ /dev/null
@@ -1,223 +0,0 @@
-// Implements serialize/deserialize of structured clones.
-// Also resolves cycles (code based on cycle.js by Douglas Crockford)
-
-function encodeRegExp (regexp)
-{
- var flags = '';
- if (regexp.global) flags += 'g';
- if (regexp.multiline) flags += 'm';
- if (regexp.ignoreCase) flags += 'i';
- return [flags, regexp.source].join(',');
-}
-
-function decodeRegExp (str)
-{
- var flags = str.match(/^[^,]*/)[0];
- var source = str.substr(flags.length + 1);
- return new RegExp(source, flags);
-}
-
-
-// The derez recurses through the object, producing the deep copy.
-
-function derez(value, path, objects, paths, buffers)
-{
- if (Buffer.isBuffer(value)) {
- var start = Buffer.concat(buffers).length;
- buffers.push(value);
- return '\x10b' + [start, value.length].join(',')
- }
- if (value instanceof Date) {
- return '\x10d' + value.toJSON();
- }
- if (value instanceof RegExp) {
- return '\x10r' + encodeRegExp(value);
- }
- if (value instanceof Error) {
- return '\x10e' + value.message
- }
- if (typeof value == 'string') {
- return value.charAt(0) == '\x10' ? '\x10s' + value : value;
- }
-
- var i, // The loop counter
- name, // Property name
- nu; // The new object or array
-
-// typeof null === 'object', so go on if this value is really an object but not
-// one of the weird builtin objects.
-
- if (typeof value === 'object' && value !== null &&
- !(value instanceof Boolean) &&
- !(value instanceof Number) &&
- !(value instanceof String)) {
-
-// If the value is an object or array, look to see if we have already
-// encountered it. If so, return a $ref/path object. This is a hard way,
-// linear search that will get slower as the number of unique objects grows.
-
- i = objects.indexOf(value);
- if (i !== -1) {
- return '\x10j' + paths[i];
- }
-
-// Otherwise, accumulate the unique value and its path.
-
- objects.push(value);
- paths.push(path);
-
-// If it is an array, replicate the array.
-
- if (Array.isArray(value)) {
- nu = [];
- for (i = 0; i < value.length; i += 1) {
- nu[i] = derez(value[i],
- path + '[' + i + ']',
- objects, paths, buffers);
- }
- } else {
-
-// If it is an object, replicate the object.
-
- nu = {};
- for (name in value) {
- if (Object.prototype.hasOwnProperty.call(value, name) && value != '__proto__') {
- nu[name] = derez(value[name],
- path + '[' + JSON.stringify(name) + ']',
- objects, paths, buffers);
- }
- }
- }
- return nu;
- }
-
- return value;
-}
-
-
-function rerez($, $$)
-{
-
-// Restore an object that was reduced by decycle. Members whose values are
-// objects of the form
-// {$ref: PATH}
-// are replaced with references to the value found by the PATH. This will
-// restore cycles. The object will be mutated.
-
-// The eval function is used to locate the values described by a PATH. The
-// root object is kept in a $ variable. A regular expression is used to
-// assure that the PATH is extremely well formed. The regexp contains nested
-// * quantifiers. That has been known to have extremely bad performance
-// problems on some browsers for very long strings. A PATH is expected to be
-// reasonably short. A PATH is allowed to belong to a very restricted subset of
-// Goessner's JSONPath.
-
-// So,
-// var s = '[{"$ref":"$"}]';
-// return JSON.retrocycle(JSON.parse(s));
-// produces an array containing a single element which is the array itself.
-
- var px =
- /^\${1,4}(?:\[(?:\d+|\"(?:[^\\\"\u0000-\u001f]|\\([\\\"\/bfnrt]|u[0-9a-zA-Z]{4}))*\")\])*$/;
-
- function redo (item) {
- if (typeof item == 'string' && item.charAt(0) == '\x10') {
- switch (item.charAt(1)) {
- case 's':
- return item.substr(2);
- case 'b':
- var bounds = item.substr(2).split(',', 2);
- return $$.slice(bounds[0] || 0, (bounds[0] || 0) + (bounds[1] || [0]));
- case 'd':
- return new Date(item.substr(2));
- case 'r':
- return decodeRegExp(item.substr(2));
- case 'e':
- return new Error(item.substr(2));
- case 'j':
- var path = item.substr(2);
- if (px.test(path)) {
- return eval(path);
- }
- default: return null;
- }
- }
-
- if (item && typeof item === 'object') {
- rez(item, $$);
- }
- return item;
- }
-
- function rez(value) {
-
-// The rez function walks recursively through the object looking for $ref
-// properties. When it finds one that has a value that is a path, then it
-// replaces the $ref object with a reference to the value that is found by
-// the path.
-
- var i, name;
-
- if (value && typeof value === 'object') {
- if (Array.isArray(value)) {
- for (i = 0; i < value.length; i += 1) {
- value[i] = redo(value[i]);
- }
- } else {
- for (name in value) {
- value[name] = redo(value[name]);
- }
- }
- }
- }
-
- $ = redo($)
-
- return $;
-};
-
-
-// Public API
-
-exports.serialize = function (object) {
- var objects = [], // Keep a reference to each unique object or array
- paths = [], // Keep the path to each unique object or array
- buffers = []; // Returned buffers
-
- var nilbyte = new Buffer([0x00]);
-
- if (Buffer.isBuffer(object)) {
- return Buffer.concat([
- nilbyte,
- object
- ]);
- }
-
- var json = new Buffer(JSON.stringify(derez(object, '$', objects, paths, buffers)));
- if (buffers.length == 0) {
- return json;
- }
-
- return Buffer.concat([
- json,
- nilbyte,
- Buffer.concat(buffers)
- ]);
-}
-
-exports.deserialize = function (buf) {
- for (var i = 0; i <= buf.length; i++) {
- if (buf[i] == 0x00 || buf[i] == null) {
- break;
- }
- }
- var jsonbuf = buf.slice(0, i);
- var bufbuf = buf.slice(i + 1);
-
- // Shortcut for only encoding a root buffer.
- if (jsonbuf.length == 0) {
- return bufbuf;
- }
-
- return rerez(JSON.parse(jsonbuf.toString('utf-8')), bufbuf);
-} \ No newline at end of file
diff --git a/node_modules/structured-clone/test/test.js b/node_modules/structured-clone/test/test.js
deleted file mode 100644
index 1a201e572..000000000
--- a/node_modules/structured-clone/test/test.js
+++ /dev/null
@@ -1,100 +0,0 @@
-var test = require('tape');
-
-test('deep cloning test', function (t) {
- t.plan(12)
-
- var clone = require('../')
-
- var a = { }
- a.b = a
- a.c = { $ref: '$' }
- a.d = new Buffer([0xde, 0xad])
- a.e = [ a, a.b ]
- a.f = new Date()
- a.g = /ab+a/i
-
- var a = clone(a);
-
- t.ok(a.b == a);
- t.ok(a.c.$ref == '$')
- t.ok(Buffer.isBuffer(a.d))
- t.ok(a.d[0] == 0xde)
- t.ok(a.d[1] == 0xad)
- t.ok(a.d.length == 2);
- t.ok(Array.isArray(a.e));
- t.ok(a.e.length == 2);
- t.ok(a.e[0] == a);
- t.ok(a.e[1] == a.b);
- t.ok(a.f instanceof Date);
- t.ok(a.g instanceof RegExp);
-})
-
-test('serializing test', function (t) {
- t.plan(14)
-
- var clone = require('../')
-
- var a = { }
- a.b = a
- a.c = { $ref: '$' }
- a.d = new Buffer([0xde, 0xad])
- a.e = [ a, a.b ]
- a.f = new Date()
- a.g = /ab+a/i
-
- var buf = clone.serialize(a);
- t.ok(buf.length, 'Buffer has length')
- t.ok(Buffer.isBuffer(buf), 'Buffer has length')
-
- var a = clone.deserialize(buf);
-
- t.ok(a.b == a);
- t.ok(a.c.$ref == '$')
- t.ok(Buffer.isBuffer(a.d))
- t.ok(a.d[0] == 0xde)
- t.ok(a.d[1] == 0xad)
- t.ok(a.d.length == 2);
- t.ok(Array.isArray(a.e));
- t.ok(a.e.length == 2);
- t.ok(a.e[0] == a);
- t.ok(a.e[1] == a.b);
- t.ok(a.f instanceof Date);
- t.ok(a.g instanceof RegExp);
-})
-
-test('deep copy root object', function (t) {
- t.plan(3);
-
- var clone = require('../');
-
- var buf = clone(new Buffer([0xca, 0xfe, 0xba, 0xbe]));
- t.ok(Buffer.isBuffer(buf));
- t.ok(buf.length == 4);
- t.ok(buf.readUInt32BE(0) == 0xcafebabe);
-});
-
-test('serializing root object', function (t) {
- t.plan(3);
-
- var clone = require('../');
-
- var buf = clone.deserialize(clone.serialize(new Buffer([0xca, 0xfe, 0xba, 0xbe])));
- t.ok(Buffer.isBuffer(buf));
- t.ok(buf.length == 4);
- t.ok(buf.readUInt32BE(0) == 0xcafebabe);
-});
-
-
-test('errors', function (t) {
- t.plan(4);
-
- var clone = require('../');
-
- var err = clone(new Error('boo!'));
- t.ok(err instanceof Error);
- t.ok(err.message == 'boo!');
-
- var err = clone.deserialize(clone.serialize(new Error('boo!')));
- t.ok(err instanceof Error);
- t.ok(err.message == 'boo!');
-}); \ No newline at end of file