From bddc6c23ea76a204b0a344a053804a801e6291e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Wa=CC=88rting?= Date: Tue, 12 Feb 2019 15:14:20 +0100 Subject: [PATCH] don't crash in node #72 Applied standard format inlined the decorators added test for few arguments --- FormData.js | 163 +++--- README.md | 2 + formdata.min.js | 22 +- package-lock.json | 1404 ++++++++++++++++++++++++++++++++++++++++++++- package.json | 9 +- test/test.js | 120 ++-- 6 files changed, 1560 insertions(+), 160 deletions(-) diff --git a/FormData.js b/FormData.js index 4beefcb..87f4aa7 100644 --- a/FormData.js +++ b/FormData.js @@ -1,7 +1,10 @@ -if (typeof FormData === 'undefined' || !FormData.prototype.keys) { +/* global FormData self Blob File */ +/* eslint-disable no-inner-declarations */ + +if (typeof Blob === 'function' && (typeof FormData === 'undefined' || !FormData.prototype.keys)) { const global = typeof window === 'object' - ? window : typeof self === 'object' - ? self : this + ? window + : typeof self === 'object' ? self : this // keep a reference to native implementation const _FormData = global.FormData @@ -16,9 +19,8 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { // https://github.com/babel/babel/issues/1966 const stringTag = global.Symbol && Symbol.toStringTag - const map = new WeakMap + const map = new WeakMap() const wm = o => map.get(o) - const arrayFrom = Array.from || (obj => [].slice.call(obj)) // Add missing stringTags to blob and files if (stringTag) { @@ -33,11 +35,11 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { // Fix so you can construct your own File try { - new File([], '') + new File([], '') // eslint-disable-line } catch (a) { - global.File = function(b, d, c) { + global.File = function File (b, d, c) { const blob = new Blob(b, c) - const t = c && void 0 !== c.lastModified ? new Date(c.lastModified) : new Date + const t = c && void 0 !== c.lastModified ? new Date(c.lastModified) : new Date() Object.defineProperties(blob, { name: { @@ -50,7 +52,7 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { value: +t }, toString: { - value() { + value () { return '[object File]' } } @@ -66,50 +68,42 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { } } - function normalizeValue([value, filename]) { - if (value instanceof Blob) + function normalizeValue ([value, filename]) { + if (value instanceof Blob) { // Should always returns a new File instance // console.assert(fd.get(x) !== fd.get(x)) value = new File([value], filename, { type: value.type, lastModified: value.lastModified }) + } return value } - function stringify(name) { - if (!arguments.length) - throw new TypeError('1 argument required, but only 0 present.') - - return [name + ''] + function ensureArgs (args, expected) { + if (args.length < expected) { + throw new TypeError(`${expected} argument required, but only ${args.length} present.`) + } } - function normalizeArgs(name, value, filename) { - if (arguments.length < 2) - throw new TypeError( - `2 arguments required, but only ${arguments.length} present.` - ) - + function normalizeArgs (name, value, filename) { return value instanceof Blob // normalize name and filename if adding an attachment - ? [name + '', value, filename !== undefined + ? [String(name), value, filename !== undefined ? filename + '' // Cast filename to string if 3th arg isn't undefined : typeof value.name === 'string' // if name prop exist ? value.name // Use File.name : 'blob'] // otherwise fallback to Blob // If no attachment, just cast the args to strings - : [name + '', value + ''] + : [String(name), String(value)] } // normalize linefeeds for textareas // https://html.spec.whatwg.org/multipage/form-elements.html#textarea-line-break-normalisation-transformation - function normalizeLinefeeds(value) { - if (typeof value === "string") { - value = value.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n") - } - return value + function normalizeLinefeeds (value) { + return value.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n') } function each (arr, cb) { @@ -122,17 +116,15 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { * @implements {Iterable} */ class FormDataPolyfill { - /** * FormData class * * @param {HTMLElement=} form */ - constructor(form) { + constructor (form) { map.set(this, Object.create(null)) - if (!form) - return this + if (!form) return this const self = this @@ -156,7 +148,6 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { }) } - /** * Append a field * @@ -165,38 +156,40 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { * @param {String=} filename filename to use with blob * @return {Undefined} */ - append(name, value, filename) { + append (name, value, filename) { + ensureArgs(arguments, 2) + ;[name, value, filename] = normalizeArgs.apply(null, arguments) const map = wm(this) - if (!map[name]) - map[name] = [] + if (!map[name]) map[name] = [] map[name].push([value, filename]) } - /** * Delete all fields values given name * * @param {String} name Field name * @return {Undefined} */ - delete(name) { - delete wm(this)[name] + delete (name) { + ensureArgs(arguments, 1) + delete wm(this)[String(name)] } - /** * Iterate over all fields as [name, value] * * @return {Iterator} */ - *entries() { + * entries () { const map = wm(this) - for (let name in map) - for (let value of map[name]) + for (let name in map) { + for (let value of map[name]) { yield [name, normalizeValue(value)] + } + } } /** @@ -206,12 +199,13 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { * @param {Object=} thisArg `this` context for callback function * @return {Undefined} */ - forEach(callback, thisArg) { - for (let [name, value] of this) + forEach (callback, thisArg) { + ensureArgs(arguments, 1) + for (let [name, value] of this) { callback.call(thisArg, value, name, this) + } } - /** * Return first field value given name * or null if non existen @@ -219,45 +213,46 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { * @param {String} name Field name * @return {String|File|null} value Fields value */ - get(name) { + get (name) { + ensureArgs(arguments, 1) const map = wm(this) + name = String(name) return map[name] ? normalizeValue(map[name][0]) : null } - /** * Return all fields values given name * * @param {String} name Fields name * @return {Array} [{String|File}] */ - getAll(name) { - return (wm(this)[name] || []).map(normalizeValue) + getAll (name) { + ensureArgs(arguments, 1) + return (wm(this)[String(name)] || []).map(normalizeValue) } - /** * Check for field name existence * * @param {String} name Field name * @return {boolean} */ - has(name) { - return name in wm(this) + has (name) { + ensureArgs(arguments, 1) + return String(name) in wm(this) } - /** * Iterate over all fields name * * @return {Iterator} */ - *keys() { - for (let [name] of this) + * keys () { + for (let [name] of this) { yield name + } } - /** * Overwrite all values given name * @@ -266,44 +261,45 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { * @param {String=} filename Filename (optional) * @return {Undefined} */ - set(name, value, filename) { + set (name, value, filename) { + ensureArgs(arguments, 2) + ;[name, value, filename] = normalizeArgs.apply(null, arguments) wm(this)[name] = [[value, filename]] } - /** * Iterate over all fields * * @return {Iterator} */ - *values() { - for (let [name, value] of this) + * values () { + for (let [, value] of this) { yield value + } } - /** * Return a native (perhaps degraded) FormData with only a `append` method * Can throw if it's not supported * * @return {FormData} */ - ['_asNative']() { - const fd = new _FormData + ['_asNative'] () { + const fd = new _FormData() - for (let [name, value] of this) + for (let [name, value] of this) { fd.append(name, value) + } return fd } - /** * [_blob description] * * @return {Blob} [description] */ - ['_blob']() { + ['_blob'] () { const boundary = '----formdata-polyfill-' + Math.random() const chunks = [] @@ -326,32 +322,31 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { chunks.push(`--${boundary}--`) - return new Blob(chunks, {type: 'multipart/form-data; boundary=' + boundary}) + return new Blob(chunks, { + type: 'multipart/form-data; boundary=' + boundary + }) } - /** * The class itself is iterable * alias for formdata.entries() * * @return {Iterator} */ - [Symbol.iterator]() { + [Symbol.iterator] () { return this.entries() } - /** * Create the default string description. * * @return {String} [object FormData] */ - toString() { + toString () { return '[object FormData]' } } - if (stringTag) { /** * Create the default string description. @@ -362,25 +357,9 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { FormDataPolyfill.prototype[stringTag] = 'FormData' } - const decorations = [ - ['append', normalizeArgs], - ['delete', stringify], - ['get', stringify], - ['getAll', stringify], - ['has', stringify], - ['set', normalizeArgs] - ] - - decorations.forEach(arr => { - const orig = FormDataPolyfill.prototype[arr[0]] - FormDataPolyfill.prototype[arr[0]] = function() { - return orig.apply(this, arr[1].apply(this, arrayFrom(arguments))) - } - }) - // Patch xhr's send method to call _blob transparently if (_send) { - XMLHttpRequest.prototype.send = function(data) { + global.XMLHttpRequest.prototype.send = function (data) { // I would check if Content-Type isn't already set // But xhr lacks getRequestHeaders functionallity // https://github.com/jimmywarting/FormData/issues/44 @@ -398,7 +377,7 @@ if (typeof FormData === 'undefined' || !FormData.prototype.keys) { if (_fetch) { const _fetch = global.fetch - global.fetch = function(input, init) { + global.fetch = function (input, init) { if (init && init.body && init.body instanceof FormDataPolyfill) { init.body = init.body['_blob']() } diff --git a/README.md b/README.md index 83d894c..913a081 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ [![npm version][npm-image]][npm-url] +[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) + ```bash npm install formdata-polyfill ``` diff --git a/formdata.min.js b/formdata.min.js index 81c8e07..cca74ec 100644 --- a/formdata.min.js +++ b/formdata.min.js @@ -1,17 +1,17 @@ ;(function(){var k;function l(a){var b=0;return function(){return barguments.length)throw new TypeError("2 arguments required, but only "+arguments.length+" present.");return b instanceof Blob?[a+"",b,void 0!==d?d+"":"string"===typeof b.name?b.name:"blob"]:[a+"",b+""]},Q=function(a){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present."); -return[a+""]},R=function(a){var b=x(a);a=b.next().value;b=b.next().value;a instanceof Blob&&(a=new File([a],b,{type:a.type,lastModified:a.lastModified}));return a},S="object"===typeof window?window:"object"===typeof self?self:this,T=S.FormData,U=S.XMLHttpRequest&&S.XMLHttpRequest.prototype.send,V=S.Request&&S.fetch;p();var W=S.Symbol&&Symbol.toStringTag,X=new WeakMap,Y=Array.from||function(a){return[].slice.call(a)};W&&(Blob.prototype[W]||(Blob.prototype[W]="Blob"),"File"in S&&!File.prototype[W]&& -(File.prototype[W]="File"));try{new File([],"")}catch(a){S.File=function(b,d,c){b=new Blob(b,c);c=c&&void 0!==c.lastModified?new Date(c.lastModified):new Date;Object.defineProperties(b,{name:{value:d},lastModifiedDate:{value:c},lastModified:{value:+c},toString:{value:function(){return"[object File]"}}});W&&Object.defineProperty(b,W,{value:"File"});return b}}p();u();var Z=function(a){X.set(this,Object.create(null));if(!a)return this;var b=this;N(a.elements,function(a){if(a.name&&!a.disabled&&"submit"!== -a.type&&"button"!==a.type)if("file"===a.type)N(a.files||[],function(c){b.append(a.name,c)});else if("select-multiple"===a.type||"select-one"===a.type)N(a.options,function(c){!c.disabled&&c.selected&&b.append(a.name,c.value)});else if("checkbox"===a.type||"radio"===a.type)a.checked&&b.append(a.name,a.value);else{var c="textarea"===a.type?O(a.value):a.value;b.append(a.name,c)}})};k=Z.prototype;k.append=function(a,b,d){var c=X.get(this);c[a]||(c[a]=[]);c[a].push([b,d])};k["delete"]=function(a){delete X.get(this)[a]}; -k.entries=function b(){var d=this,c,e,f,g,h,q;return M(b,function(b){switch(b.b){case 1:c=X.get(d),f=new G(c);case 2:var t;a:{for(t=f;0= 2.1.2 < 3" } }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, "indexof": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", @@ -1684,6 +2362,27 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, + "inquirer": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-5.2.0.tgz", + "integrity": "sha512-E9BmnJbAKLPGonz0HeWHtbKf+EeSP93paWO3ZYoUpq/aowXvYGjjCSuashhXPpzbArIjBbji39THkxTz9ZeEUQ==", + "dev": true, + "requires": { + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.0", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^2.1.0", + "figures": "^2.0.0", + "lodash": "^4.3.0", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rxjs": "^5.5.2", + "string-width": "^2.1.0", + "strip-ansi": "^4.0.0", + "through": "^2.3.6" + } + }, "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", @@ -1704,6 +2403,12 @@ } } }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, "is-binary-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", @@ -1719,6 +2424,12 @@ "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", @@ -1739,6 +2450,12 @@ } } }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -1770,6 +2487,12 @@ "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", "dev": true }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, "is-glob": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", @@ -1808,6 +2531,36 @@ "isobject": "^3.0.1" } }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, + "requires": { + "has": "^1.0.1" + } + }, + "is-resolvable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", + "dev": true + }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } + }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -1841,6 +2594,49 @@ "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", "dev": true }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + }, + "js-yaml": { + "version": "3.12.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.1.tgz", + "integrity": "sha512-um46hB9wNOKlwkHgiuyEVAybXBjwFUV0Z/RaHJblRd9DXltue9FTYvzCr9ErQrK9Adz5MU4gHWVaNUfdmrC8qA==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, + "jsx-ast-utils": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz", + "integrity": "sha1-6AGxs5mF4g//yHtA43SAgOLcrH8=", + "dev": true, + "requires": { + "array-includes": "^3.0.3" + } + }, "karma": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/karma/-/karma-4.0.0.tgz", @@ -1916,6 +2712,38 @@ "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "dev": true }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, "lodash": { "version": "4.17.11", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", @@ -2031,6 +2859,12 @@ "mime-db": "~1.37.0" } }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -2126,6 +2960,12 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, "nan": { "version": "2.12.1", "resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz", @@ -2152,12 +2992,36 @@ "to-regex": "^3.0.1" } }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, "negotiator": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", "dev": true }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", @@ -2173,6 +3037,12 @@ "integrity": "sha1-l33/1xdgErnsMNKjnbXPcqBDnt0=", "dev": true }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, "object-component": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", @@ -2210,6 +3080,12 @@ } } }, + "object-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz", + "integrity": "sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg==", + "dev": true + }, "object-visit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", @@ -2246,6 +3122,15 @@ "wrappy": "1" } }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", @@ -2256,12 +3141,67 @@ "wordwrap": "~0.0.2" } }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + }, + "dependencies": { + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + } + } + }, "os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, "parseqs": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", @@ -2298,36 +3238,169 @@ "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", "dev": true }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "dev": true, + "requires": { + "pify": "^2.0.0" + } + }, "pathval": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", "dev": true }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pkg-conf": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pkg-conf/-/pkg-conf-2.1.0.tgz", + "integrity": "sha1-ISZRTKbyq/69FoWW3xi6V4Z/AFg=", + "dev": true, + "requires": { + "find-up": "^2.0.0", + "load-json-file": "^4.0.0" + }, + "dependencies": { + "load-json-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0", + "strip-bom": "^3.0.0" + } + }, + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, + "requires": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + } + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } + } + }, + "pkg-config": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pkg-config/-/pkg-config-1.1.1.tgz", + "integrity": "sha1-VX7yLXPaPIg3EHdmxS6tq94pj+Q=", + "dev": true, + "requires": { + "debug-log": "^1.0.0", + "find-root": "^1.0.0", + "xtend": "^4.0.1" + } + }, + "pkg-dir": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "dev": true, + "requires": { + "find-up": "^2.1.0" + } + }, + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", + "dev": true + }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", "dev": true }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, + "prop-types": { + "version": "15.7.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.1.tgz", + "integrity": "sha512-f8Lku2z9kERjOCcnDOPm68EBJAO2K00Q5mSgPAUE/gJuBgsYLbVy6owSrtcHj90zt8PvW+z0qaIIgsIhHOa1Qw==", + "dev": true, + "requires": { + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, "qjobs": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.2.0.tgz", @@ -2358,6 +3431,33 @@ "unpipe": "1.0.0" } }, + "react-is": { + "version": "16.8.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.8.1.tgz", + "integrity": "sha512-ioMCzVDWvCvKD8eeT+iukyWrBGrA3DiFYkXfBsVYIRdaREZuBjENG+KjrikavCLasozqRWTwFUagU/O4vPpRMA==", + "dev": true + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "dev": true, + "requires": { + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "dev": true, + "requires": { + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" + } + }, "readable-stream": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", @@ -2394,6 +3494,12 @@ "safe-regex": "^1.1.0" } }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -2412,18 +3518,53 @@ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", "dev": true }, + "require-uncached": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "dev": true, + "requires": { + "caller-path": "^0.1.0", + "resolve-from": "^1.0.0" + } + }, "requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", "dev": true }, + "resolve": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", + "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "dev": true + }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", "dev": true }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, "ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", @@ -2445,6 +3586,30 @@ "glob": "^7.1.3" } }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "^2.1.0" + } + }, + "run-parallel": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", + "integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==", + "dev": true + }, + "rxjs": { + "version": "5.5.12", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.12.tgz", + "integrity": "sha512-xx2itnL5sBbqeeiVgNPVuQQ1nC8Jp2WfNJhXWHmElW9YmrpS9UVnNzhP3EH3HFqexO5Tlp8GhYY+WEcqcVMvGw==", + "dev": true, + "requires": { + "symbol-observable": "1.0.1" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -2466,6 +3631,12 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "dev": true + }, "set-value": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", @@ -2495,6 +3666,36 @@ "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", "dev": true }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0" + } + }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -2725,6 +3926,38 @@ "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "dev": true }, + "spdx-correct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.3.tgz", + "integrity": "sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g==", + "dev": true + }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -2734,6 +3967,49 @@ "extend-shallow": "^3.0.0" } }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "standard": { + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/standard/-/standard-12.0.1.tgz", + "integrity": "sha512-UqdHjh87OG2gUrNCSM4QRLF5n9h3TFPwrCNyVlkqu31Hej0L/rc8hzKqVvkb2W3x0WMq7PzZdkLfEcBhVOR6lg==", + "dev": true, + "requires": { + "eslint": "~5.4.0", + "eslint-config-standard": "12.0.0", + "eslint-config-standard-jsx": "6.0.2", + "eslint-plugin-import": "~2.14.0", + "eslint-plugin-node": "~7.0.1", + "eslint-plugin-promise": "~4.0.0", + "eslint-plugin-react": "~7.11.1", + "eslint-plugin-standard": "~4.0.0", + "standard-engine": "~9.0.0" + } + }, + "standard-engine": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/standard-engine/-/standard-engine-9.0.0.tgz", + "integrity": "sha512-ZfNfCWZ2Xq67VNvKMPiVMKHnMdvxYzvZkf1AH8/cw2NLDBm5LRsxMqvEJpsjLI/dUosZ3Z1d6JlHDp5rAvvk2w==", + "dev": true, + "requires": { + "deglob": "^2.1.0", + "get-stdin": "^6.0.0", + "minimist": "^1.1.0", + "pkg-conf": "^2.0.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } + } + }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -2790,6 +4066,16 @@ } } }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -2799,6 +4085,35 @@ "safe-buffer": "~5.1.0" } }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + } + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, "supports-color": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", @@ -2808,6 +4123,38 @@ "has-flag": "^3.0.0" } }, + "symbol-observable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz", + "integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ=", + "dev": true + }, + "table": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.3.tgz", + "integrity": "sha512-S7rnFITmBH1EnyKcvxBh1LjYeQMmnZtCXSEbHcH6S0NoKit24ZuFO/T1vDcLdYsLQkM188PVVhQmzKIuThNkKg==", + "dev": true, + "requires": { + "ajv": "^6.0.1", + "ajv-keywords": "^3.0.0", + "chalk": "^2.1.0", + "lodash": "^4.17.4", + "slice-ansi": "1.0.0", + "string-width": "^2.1.1" + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -2865,6 +4212,15 @@ "repeat-string": "^1.6.1" } }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -2922,6 +4278,12 @@ } } }, + "uniq": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", + "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", + "dev": true + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -2974,6 +4336,15 @@ "integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==", "dev": true }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, "urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", @@ -3008,6 +4379,16 @@ "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", "dev": true }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, "void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", @@ -3035,6 +4416,15 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, "ws": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", @@ -3052,6 +4442,12 @@ "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=", "dev": true }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", diff --git a/package.json b/package.json index 6b8ab2a..26e659d 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "formdata-polyfill", - "version": "3.0.15", + "version": "3.0.16", "description": "HTML5 `FormData` polyfill for Browsers.", "main": "formdata.min.js", "scripts": { "build": "node build", - "prepare": "npm run build", - "test": "karma start --single-run --browsers ChromeHeadless karma.conf.js" + "prepare": "npm run test && npm run build", + "test": "standard ./FormData.js && karma start --single-run --browsers ChromeHeadless karma.conf.js" }, "repository": { "type": "git", @@ -35,6 +35,7 @@ "karma-chai": "^0.1.0", "karma-chrome-launcher": "^2.2.0", "karma-mocha": "^1.3.0", - "mocha": "^5.2.0" + "mocha": "^5.2.0", + "standard": "^12.0.1" } } diff --git a/test/test.js b/test/test.js index 5a71976..74f5eb3 100644 --- a/test/test.js +++ b/test/test.js @@ -1,28 +1,29 @@ +/* global it describe assert expect Blob FormData */ const native = window.FormData window.FormData = undefined class Polyfill { - constructor(args) { + constructor (args) { return new FormData(args) } } -const nativeFile = window.File +const NativeFile = window.File // Want to simulate the kind of error we get in // old safari & ie when constructing a file -window.File = new Proxy(nativeFile, { - construct(target, args) { - throw new Error +window.File = new Proxy(NativeFile, { + construct (target, args) { + throw new Error() } }) ;[native, Polyfill].forEach(FormData => { - function create_formdata(...args) { - const fd = new FormData() - for (let arg of args) { - fd.append(...arg) - } - return fd + function createFormData(...args) { + const fd = new FormData() + for (let arg of args) { + fd.append(...arg) + } + return fd } function create_form(str) { @@ -36,80 +37,94 @@ window.File = new Proxy(nativeFile, { describe('FormData ' + (FormData === native ? 'native' : 'polyfill'), () => { describe('append', () => { + it('throwOnFewArgs', () => { + expect(() => { + var fd = new FormData() + fd.append('key') + }).throw() + }) + it('testFormDataAppend1', () => { - assert.equal(create_formdata(['key', 'value1']).get('key'), 'value1') + assert.equal(createFormData(['key', 'value1']).get('key'), 'value1') }) it('testFormDataAppend2', () => { - assert.equal(create_formdata(['key', 'value2'], ['key', 'value1']).get('key'), 'value2') + assert.equal(createFormData(['key', 'value2'], ['key', 'value1']).get('key'), 'value2') }) it('testFormDataAppendUndefined1', () => { - assert.equal(create_formdata(['key', undefined]).get('key'), 'undefined') + assert.equal(createFormData(['key', undefined]).get('key'), 'undefined') }) it('testFormDataAppendUndefined2', () => { - assert.equal(create_formdata(['key', undefined], ['key', 'value1']).get('key'), 'undefined') + assert.equal(createFormData(['key', undefined], ['key', 'value1']).get('key'), 'undefined') }) it('testFormDataAppendNull1', () => { - assert.equal(create_formdata(['key', null]).get('key'), 'null') + assert.equal(createFormData(['key', null]).get('key'), 'null') }) it('testFormDataAppendNull2', () => { - assert.equal(create_formdata(['key', null], ['key', 'value1']).get('key'), 'null') + assert.equal(createFormData(['key', null], ['key', 'value1']).get('key'), 'null') }) it('testFormDataAppendToForm1', () => { - var fd = new FormData(document.createElement('form')) - fd.append('key', 'value1') - assert.equal(fd.get('key'), 'value1') + var fd = new FormData(document.createElement('form')) + fd.append('key', 'value1') + assert.equal(fd.get('key'), 'value1') }) it('testFormDataAppendToForm2', () => { - var fd = new FormData(document.createElement('form')) - fd.append('key', 'value2') - fd.append('key', 'value1') - assert.equal(fd.get('key'), 'value2') + var fd = new FormData(document.createElement('form')) + fd.append('key', 'value2') + fd.append('key', 'value1') + assert.equal(fd.get('key'), 'value2') }) it('testFormDataAppendToFormUndefined1', () => { - var fd = new FormData(document.createElement('form')) - fd.append('key', undefined) - assert.equal(fd.get('key'), 'undefined') + var fd = new FormData(document.createElement('form')) + fd.append('key', undefined) + assert.equal(fd.get('key'), 'undefined') }) it('testFormDataAppendToFormUndefined2', () => { - var fd = new FormData(document.createElement('form')) - fd.append('key', undefined) - fd.append('key', 'value1') - assert.equal(fd.get('key'), 'undefined') + var fd = new FormData(document.createElement('form')) + fd.append('key', undefined) + fd.append('key', 'value1') + assert.equal(fd.get('key'), 'undefined') }) it('testFormDataAppendToFormNull1', () => { - var fd = new FormData(document.createElement('form')) - fd.append('key', null) - assert.equal(fd.get('key'), 'null') + var fd = new FormData(document.createElement('form')) + fd.append('key', null) + assert.equal(fd.get('key'), 'null') }) it('testFormDataAppendToFormNull2', () => { - var fd = new FormData(document.createElement('form')) - fd.append('key', null) - fd.append('key', 'value1') - assert.equal(fd.get('key'), 'null') + var fd = new FormData(document.createElement('form')) + fd.append('key', null) + fd.append('key', 'value1') + assert.equal(fd.get('key'), 'null') }) it('testFormDataAppendEmptyBlob', () => { - var fd = create_formdata(['key', new Blob, 'blank.txt']).get('key') - assert.equal(fd.name, 'blank.txt') - assert.equal(fd.type, '') - assert.equal(fd.size, 0) + var fd = createFormData(['key', new Blob(), 'blank.txt']).get('key') + assert.equal(fd.name, 'blank.txt') + assert.equal(fd.type, '') + assert.equal(fd.size, 0) }) }) describe('has', () => { + it('throwOnFewArgs', () => { + expect(() => { + var fd = new FormData() + fd.has() + }).throw() + }) + it('FormData.has()', () => { - var fd = new FormData + var fd = new FormData() fd.append('n1', 'value') assert.equal(fd.has('n1'), true) assert.equal(fd.has('n2'), false) @@ -122,8 +137,15 @@ window.File = new Proxy(nativeFile, { }) describe('delete', () => { + it('throwOnFewArgs', () => { + expect(() => { + var fd = new FormData() + fd.delete() + }).throw() + }) + it('FormData.delete()', () => { - var fd = new FormData + var fd = new FormData() fd.append('name', 'value') assert.equal(fd.has('name'), true) fd.delete('name') @@ -151,19 +173,19 @@ window.File = new Proxy(nativeFile, { // `Object.prototype.toString.call` to return correct type of the polyfilled // File constructor it('Shold return correct filename with File', () => { - const fd = create_formdata(['key', new nativeFile([], 'doc.txt')]) + const fd = createFormData(['key', new NativeFile([], 'doc.txt')]) const mockFile = fd.get('key') assert.equal('doc.txt', mockFile.name) }) it('Shold return correct filename with Blob filename', () => { - const fd = create_formdata(['key', new Blob, 'doc.txt']) + const fd = createFormData(['key', new Blob(), 'doc.txt']) const mockFile = fd.get('key') assert.equal('doc.txt', mockFile.name) }) it('Shold return correct filename with just Blob', () => { - const fd = create_formdata(['key', new Blob]) + const fd = createFormData(['key', new Blob()]) const mockFile = fd.get('key') assert.equal('blob', mockFile.name) }) @@ -207,13 +229,13 @@ window.File = new Proxy(nativeFile, { }) it('Should not convert LF to CRLF when provided by append', () => { - const fd = create_formdata(['key', '\n']) + const fd = createFormData(['key', '\n']) const value = fd.get('key') assert.equal('\n', value) }) it('Should not convert CR to CRLF when provided by append', () => { - const fd = create_formdata(['key', '\r']) + const fd = createFormData(['key', '\r']) const value = fd.get('key') assert.equal('\r', value) })