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

datatype-expansion

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datatype-expansion - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

src/.nyc_output/15ad52b1-13cf-4041-be72-6516085be5bb.json

2

dist/datatype-expansion.js

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

var expansion=function(e){"use strict";function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function y(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(e){if("string"==typeof e)return u(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,r):void 0}}(e))){var r=0,t=function(){};return{s:t,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o,i=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}var c=require("lodash"),p=require("./util").isOpaqueType;function l(t,n,o,i){if("string"==typeof t)try{JSON.parse(t),t={type:"json",content:t}}catch(e){}if("string"==typeof t){if(/^\(.+\)$/.test(t)&&(t=t.match(/^\((.+)\)$/)[1]),p(t)||"object"===t||"array"===t)return{type:t};if(t.endsWith("?")&&p(t.replace("?","")))return b({type:"union",anyOf:[{type:t.replace("?","")},{type:"nil"}]},n,o,i);if(t.endsWith("[]"))return{type:"array",items:l(t.match(/^(.+)\[]$/)[1],n,o,i)};if(/^[^|\s]+(?:\|[^|\s]+)+$/.test(t.replace(/\s+/g,"")))return b({anyOf:t.split("|").map(function(e){return e.trim()}),type:"union"},n,o,i);if(t in n){if(t in o)return{type:"$recur"};o=Object.assign((u=!0,(a=t)in(r={})?Object.defineProperty(r,a,{value:u,enumerable:!0,configurable:!0,writable:!0}):r[a]=u,r),o);var e=n[t];return i.trackOriginalType&&"object"!==f(e)&&(e={type:e}),e=l(e,n,o,i),i.trackOriginalType&&(e.originalType=t),e}throw new Error("could not resolve: "+t)}if("object"!==f(t))throw new Error("form can only be a string or an object");var r,a,u;if(t=c.cloneDeep(t),Array.isArray(t)&&(t={type:t}),t.type=t.type||t.properties&&"object"||t.items&&"array"||i.topLevel||"any","string"==typeof t.type){if("array"===t.type)return d(t,n,o,i);if("object"===t.type)return m(t,n,o,i);if("union"===t.type)return b(t,n,o,i);t.type in n?(t=s(t,n,o,i)).type=l(t.type,n,o,i):t=Object.assign(t,l(t.type,n,o,i))}else Array.isArray(t.type)?(t=s(t,n,o,i)).type=t.type.map(function(e){return l(e,n,o,i)}):"object"===f(t.type)?(t=s(t,n,o,i)).type=l(t.type,n,o,i):t=Object.assign(t,l(t.type,n,o,i));return null!=t.facets&&c.each(t.facets,function(e,r){t.facets[r]=l(e,n,o,i)}),t}function s(e,r,t,n){return void 0!==e.properties&&(e=m(e,r,t,n)),void 0!==e.anyOf&&(e=b(e,r,t,n)),void 0!==e.items&&(e=d(e,r,t,n)),e}function d(e,r,t,n){return e.items=l(e.items||"any",r,t,n),e}function m(e,r,t,n){var o=e.properties;for(var i in o)if(Object.prototype.hasOwnProperty.call(o,i)){var a=l(o[i]||"any",r,t,n);i.endsWith("?")&&(delete o[i],i=i.slice(0,-1),a.required=!1),void 0===a.required&&(a.required=!0),o[i]=a}return void 0===e.additionalProperties&&(e.additionalProperties=!0),e}function b(e,r,t,n){return e.anyOf=e.anyOf.map(function(e){return l(e,r,t,n)}),e}module.exports.expandedForm=function(r,t,n){var o={};"object"===f(n)&&(n=(o=n).callback);var i={};for(var e in t)if(t[e]===r){i[e]=!0;break}if(null==n)return l(r,t,i,o);setTimeout(function(){var e;try{e=l(r,t,i,o)}catch(e){return void n(e,null)}n(null,e)},0)};var r=Object.freeze({__proto__:null}),v=require("lodash"),a=require("./minType"),h=require("./util").consistencyCheck,O=require("./util").isOpaqueType;function j(c,r){var e=(c=v.cloneDeep(c)).type;if(O(e))return h(c);if("array"===e)return c.items=j(c.items||{type:"any"},r),h(c);if("object"===e){var t=c.properties,p=[v.cloneDeep(c)];if(p[0].properties={},v.each(t,function(e,i){var a=j(e,r);if("union"===a.type&&!1!==r.hoistUnions){var u=[];a.anyOf.forEach(function(e){"boolean"==typeof c.required&&(e.required=a.required);var r,t=y(p);try{for(t.s();!(r=t.n()).done;){var n=r.value;n=v.cloneDeep(n);var o=Object.assign({},a,e);delete o.anyOf,n.properties[i]=o,u.push(n)}}catch(e){t.e(e)}finally{t.f()}}),p=u}else p=p.map(function(e){return e.properties[i]=a,e})}),1===p.length)return h(p[0]);if(1<p.length)return c.type="union",delete c.properties,delete c.additionalProperties,c.anyOf=p,h(c)}else{if("union"===e)return c.anyOf=c.anyOf.map(function(e){return j("type"in e?e:{type:e},r)}),h(c);if("object"===f(e)){var n=function r(e){if(void 0!==e.properties)return"object";if(void 0!==e.items)return"array";if("string"==typeof e.type)return e.type;if("object"===f(e.type)){if(!Array.isArray(e.type))return r(e.type);var t=e.type.map(function(e){try{return r(e)}catch(e){return null}}).filter(function(e){return null!==e})[0];if(void 0!==t)return t}throw new Error("Cannot find top level class for node, not in expanded form")}(c),o=v.cloneDeep(c);switch(o.type=n){case"object":o.properties=o.properties||{};break;case"array":o.items=o.items||{type:"any"};break;case"union":o.anyOf=o.anyOf||[]}if(Array.isArray(e))return o=v.cloneDeep(e).map(function(e){return j(e,r)}).reduce(function(e,r){return a(r,e)},j(o,r));var i=j(e,r);return a(i,j(o,r))}}return c}module.exports.canonicalForm=function(r,t){var n={};if("object"===f(t)&&(t=(n=t).callback),null==t)return j(r,n);setTimeout(function(){var e;try{e=j(r,n)}catch(e){return void t(e,null)}t(null,e)},0)};var t=Object.freeze({__proto__:null}),n={expandedForm:r.expandedForm,canonicalForm:t.canonicalForm},o=n.expandedForm,i=n.canonicalForm;return e.canonicalForm=i,e.default=n,e.expandedForm=o,e}({});
var expansion=function(e){"use strict";function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function y(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return c(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==t.return||t.return()}finally{if(u)throw i}}}}var p=require("lodash"),l=require("./util").isOpaqueType;function s(t,n,o,i){if("string"==typeof t)try{JSON.parse(t),t={type:"json",content:t}}catch(e){}if("string"==typeof t){if(/^\(.+\)$/.test(t)&&(t=t.match(/^\((.+)\)$/)[1]),l(t)||"object"===t||"array"===t)return{type:t};if(t.endsWith("?")&&l(t.replace("?","")))return v({type:"union",anyOf:[{type:t.replace("?","")},{type:"nil"}]},n,o,i);if(t.endsWith("[]"))return{type:"array",items:s(t.match(/^(.+)\[]$/)[1],n,o,i)};if(/^[^|\s]+(?:\|[^|\s]+)+$/.test(t.replace(/\s+/g,"")))return v({anyOf:t.split("|").map(function(e){return e.trim()}),type:"union"},n,o,i);if(t in n){if(t in o)return{type:"$recur"};o=Object.assign((u=!0,(a=t)in(r={})?Object.defineProperty(r,a,{value:u,enumerable:!0,configurable:!0,writable:!0}):r[a]=u,r),o);var e=n[t];return i.trackOriginalType&&"object"!==f(e)&&(e={type:e}),e=s(e,n,o,i),i.trackOriginalType&&(e.originalType=t),e}throw new Error("could not resolve: "+t)}if("object"!==f(t))throw new Error("form can only be a string or an object");var r,a,u;if(t=p.cloneDeep(t),Array.isArray(t)&&(t={type:t}),t.type=t.type||t.properties&&"object"||t.items&&"array"||i.topLevel||"any","string"==typeof t.type){if("array"===t.type)return m(t,n,o,i);if("object"===t.type)return b(t,n,o,i);if("union"===t.type)return v(t,n,o,i);t.type in n?(t=d(t,n,o,i)).type=s(t.type,n,o,i):t=Object.assign(t,s(t.type,n,o,i))}else Array.isArray(t.type)?(t=d(t,n,o,i)).type=t.type.map(function(e){return s(e,n,o,i)}):"object"===f(t.type)?(t=d(t,n,o,i)).type=s(t.type,n,o,i):t=Object.assign(t,s(t.type,n,o,i));return null!=t.facets&&p.each(t.facets,function(e,r){t.facets[r]=s(e,n,o,i)}),t}function d(e,r,t,n){return void 0!==e.properties&&(e=b(e,r,t,n)),void 0!==e.anyOf&&(e=v(e,r,t,n)),void 0!==e.items&&(e=m(e,r,t,n)),e}function m(e,r,t,n){return e.items=s(e.items||"any",r,t,n),e}function b(e,r,t,n){var o=e.properties;for(var i in o)if(Object.prototype.hasOwnProperty.call(o,i)){var a=s(o[i]||"any",r,t,n);i.endsWith("?")&&(delete o[i],i=i.slice(0,-1),a.required=!1),void 0===a.required&&(a.required=!0),o[i]=a}return void 0===e.additionalProperties&&(e.additionalProperties=!0),e}function v(e,r,t,n){return e.anyOf=e.anyOf.map(function(e){return s(e,r,t,n)}),e}module.exports.expandedForm=function(r,t,n){var o={};"object"===f(n)&&(n=(o=n).callback);var i={};for(var e in t)if(t[e]===r){i[e]=!0;break}if(null==n)return s(r,t,i,o);setTimeout(function(){var e;try{e=s(r,t,i,o)}catch(e){return void n(e,null)}n(null,e)},0)};var r=Object.freeze({__proto__:null}),h=require("lodash"),a=require("./minType"),u=require("./util").consistencyCheck,O=require("./util").isOpaqueType;function j(c,r){var e=(c=h.cloneDeep(c)).type;if(O(e))return u(c);if("array"===e)return c.items=j(c.items||{type:"any"},r),u(c);if("object"===e){var t=c.properties,p=[h.cloneDeep(c)];if(p[0].properties={},h.each(t,function(e,i){var a=j(e,r);if("union"===a.type&&!1!==r.hoistUnions){var u=[];a.anyOf.forEach(function(e){"boolean"==typeof c.required&&(e.required=a.required);var r,t=y(p);try{for(t.s();!(r=t.n()).done;){var n=r.value;n=h.cloneDeep(n);var o=Object.assign({},a,e);delete o.anyOf,n.properties[i]=o,u.push(n)}}catch(e){t.e(e)}finally{t.f()}}),p=u}else p=p.map(function(e){return e.properties[i]=a,e})}),1===p.length)return u(p[0]);if(1<p.length)return c.type="union",delete c.properties,delete c.additionalProperties,c.anyOf=p,u(c)}else{if("union"===e)return c.anyOf=c.anyOf.map(function(e){return j("type"in e?e:{type:e},r)}),u(c);if("object"===f(e)){var n=function r(e){if(void 0!==e.properties)return"object";if(void 0!==e.items)return"array";if("string"==typeof e.type)return e.type;if("object"===f(e.type)){if(!Array.isArray(e.type))return r(e.type);var t=e.type.map(function(e){try{return r(e)}catch(e){return null}}).filter(function(e){return null!==e})[0];if(void 0!==t)return t}throw new Error("Cannot find top level class for node, not in expanded form")}(c),o=h.cloneDeep(c);switch(o.type=n){case"object":o.properties=o.properties||{};break;case"array":o.items=o.items||{type:"any"};break;case"union":o.anyOf=o.anyOf||[]}if(Array.isArray(e))return o=h.cloneDeep(e).map(function(e){return j(e,r)}).reduce(function(e,r){return a(r,e)},j(o,r));var i=j(e,r);return a(i,j(o,r))}}return c}module.exports.canonicalForm=function(r,t){var n={};if("object"===f(t)&&(t=(n=t).callback),null==t)return j(r,n);setTimeout(function(){var e;try{e=j(r,n)}catch(e){return void t(e,null)}t(null,e)},0)};var t=Object.freeze({__proto__:null}),n={expandedForm:r.expandedForm,canonicalForm:t.canonicalForm},o=n.expandedForm,i=n.canonicalForm;return e.canonicalForm=i,e.default=n,e.expandedForm=o,e}({});
//# sourceMappingURL=datatype-expansion.js.map
{
"name": "datatype-expansion",
"version": "0.4.0",
"version": "0.4.1",
"description": "Utility tool to expand a given RAML type and create a canonical form",

@@ -34,12 +34,12 @@ "main": "src/index.js",

"devDependencies": {
"@babel/core": "^7.7.5",
"@babel/preset-env": "^7.7.6",
"@babel/core": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"babel-plugin-lodash": "^3.3.4",
"chai": "^4.1.1",
"mkdirp": "^1.0.4",
"mocha": "^7.1.2",
"mocha": "^8.0.1",
"npm-run-all": "^4.1.5",
"nyc": "^15.0.1",
"nyc": "^15.1.0",
"rimraf": "^3.0.0",
"rollup": "^2.7.3",
"rollup": "^2.21.0",
"rollup-plugin-babel": "^4.3.3",

@@ -49,6 +49,6 @@ "rollup-plugin-commonjs": "^10.1.0",

"rollup-plugin-uglify": "^6.0.4",
"standard": "^14.3.1"
"standard": "^14.3.4"
},
"dependencies": {
"lodash": "^4.17.4"
"lodash": "^4.17.19"
},

@@ -55,0 +55,0 @@ "files": [

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

{"processes":{"38190aed-1a5b-4bae-a5db-ca5077e488f8":{"parent":null,"children":[]},"e0f4b407-a7f6-4b3f-bfe2-1b31e9145f35":{"parent":null,"children":[]}},"files":{"/home/travis/build/raml-org/datatype-expansion/src/canonical.js":["38190aed-1a5b-4bae-a5db-ca5077e488f8","e0f4b407-a7f6-4b3f-bfe2-1b31e9145f35"],"/home/travis/build/raml-org/datatype-expansion/src/expanded.js":["38190aed-1a5b-4bae-a5db-ca5077e488f8","e0f4b407-a7f6-4b3f-bfe2-1b31e9145f35"],"/home/travis/build/raml-org/datatype-expansion/src/index.js":["38190aed-1a5b-4bae-a5db-ca5077e488f8","e0f4b407-a7f6-4b3f-bfe2-1b31e9145f35"],"/home/travis/build/raml-org/datatype-expansion/src/minType.js":["38190aed-1a5b-4bae-a5db-ca5077e488f8","e0f4b407-a7f6-4b3f-bfe2-1b31e9145f35"],"/home/travis/build/raml-org/datatype-expansion/src/util.js":["38190aed-1a5b-4bae-a5db-ca5077e488f8","e0f4b407-a7f6-4b3f-bfe2-1b31e9145f35"]},"externalIds":{}}
{"processes":{"15ad52b1-13cf-4041-be72-6516085be5bb":{"parent":null,"children":[]},"680c10a3-77b3-4f5c-a8f3-5f95538a87be":{"parent":null,"children":[]}},"files":{"/home/travis/build/raml-org/datatype-expansion/src/canonical.js":["15ad52b1-13cf-4041-be72-6516085be5bb","680c10a3-77b3-4f5c-a8f3-5f95538a87be"],"/home/travis/build/raml-org/datatype-expansion/src/expanded.js":["15ad52b1-13cf-4041-be72-6516085be5bb","680c10a3-77b3-4f5c-a8f3-5f95538a87be"],"/home/travis/build/raml-org/datatype-expansion/src/index.js":["15ad52b1-13cf-4041-be72-6516085be5bb","680c10a3-77b3-4f5c-a8f3-5f95538a87be"],"/home/travis/build/raml-org/datatype-expansion/src/minType.js":["15ad52b1-13cf-4041-be72-6516085be5bb","680c10a3-77b3-4f5c-a8f3-5f95538a87be"],"/home/travis/build/raml-org/datatype-expansion/src/util.js":["15ad52b1-13cf-4041-be72-6516085be5bb","680c10a3-77b3-4f5c-a8f3-5f95538a87be"]},"externalIds":{}}

Sorry, the diff of this file is not supported yet

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