diff options
| author | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 | 
|---|---|---|
| committer | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 | 
| commit | 5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch) | |
| tree | 360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/levn/lib | |
| parent | b500a50f1b97d93c98b36ed9a980f8188d648147 (diff) | |
| download | LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip  | |
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/levn/lib')
| -rw-r--r-- | node_modules/levn/lib/cast.js | 298 | ||||
| -rw-r--r-- | node_modules/levn/lib/coerce.js | 285 | ||||
| -rw-r--r-- | node_modules/levn/lib/index.js | 22 | ||||
| -rw-r--r-- | node_modules/levn/lib/parse-string.js | 113 | ||||
| -rw-r--r-- | node_modules/levn/lib/parse.js | 102 | 
5 files changed, 820 insertions, 0 deletions
diff --git a/node_modules/levn/lib/cast.js b/node_modules/levn/lib/cast.js new file mode 100644 index 0000000..411e29d --- /dev/null +++ b/node_modules/levn/lib/cast.js @@ -0,0 +1,298 @@ +// Generated by LiveScript 1.4.0 +(function(){ +  var parsedTypeCheck, types, toString$ = {}.toString; +  parsedTypeCheck = require('type-check').parsedTypeCheck; +  types = { +    '*': function(value, options){ +      switch (toString$.call(value).slice(8, -1)) { +      case 'Array': +        return typeCast(value, { +          type: 'Array' +        }, options); +      case 'Object': +        return typeCast(value, { +          type: 'Object' +        }, options); +      default: +        return { +          type: 'Just', +          value: typesCast(value, [ +            { +              type: 'Undefined' +            }, { +              type: 'Null' +            }, { +              type: 'NaN' +            }, { +              type: 'Boolean' +            }, { +              type: 'Number' +            }, { +              type: 'Date' +            }, { +              type: 'RegExp' +            }, { +              type: 'Array' +            }, { +              type: 'Object' +            }, { +              type: 'String' +            } +          ], (options.explicit = true, options)) +        }; +      } +    }, +    Undefined: function(it){ +      if (it === 'undefined' || it === void 8) { +        return { +          type: 'Just', +          value: void 8 +        }; +      } else { +        return { +          type: 'Nothing' +        }; +      } +    }, +    Null: function(it){ +      if (it === 'null') { +        return { +          type: 'Just', +          value: null +        }; +      } else { +        return { +          type: 'Nothing' +        }; +      } +    }, +    NaN: function(it){ +      if (it === 'NaN') { +        return { +          type: 'Just', +          value: NaN +        }; +      } else { +        return { +          type: 'Nothing' +        }; +      } +    }, +    Boolean: function(it){ +      if (it === 'true') { +        return { +          type: 'Just', +          value: true +        }; +      } else if (it === 'false') { +        return { +          type: 'Just', +          value: false +        }; +      } else { +        return { +          type: 'Nothing' +        }; +      } +    }, +    Number: function(it){ +      return { +        type: 'Just', +        value: +it +      }; +    }, +    Int: function(it){ +      return { +        type: 'Just', +        value: +it +      }; +    }, +    Float: function(it){ +      return { +        type: 'Just', +        value: +it +      }; +    }, +    Date: function(value, options){ +      var that; +      if (that = /^\#([\s\S]*)\#$/.exec(value)) { +        return { +          type: 'Just', +          value: new Date(+that[1] || that[1]) +        }; +      } else if (options.explicit) { +        return { +          type: 'Nothing' +        }; +      } else { +        return { +          type: 'Just', +          value: new Date(+value || value) +        }; +      } +    }, +    RegExp: function(value, options){ +      var that; +      if (that = /^\/([\s\S]*)\/([gimy]*)$/.exec(value)) { +        return { +          type: 'Just', +          value: new RegExp(that[1], that[2]) +        }; +      } else if (options.explicit) { +        return { +          type: 'Nothing' +        }; +      } else { +        return { +          type: 'Just', +          value: new RegExp(value) +        }; +      } +    }, +    Array: function(value, options){ +      return castArray(value, { +        of: [{ +          type: '*' +        }] +      }, options); +    }, +    Object: function(value, options){ +      return castFields(value, { +        of: {} +      }, options); +    }, +    String: function(it){ +      var that; +      if (toString$.call(it).slice(8, -1) !== 'String') { +        return { +          type: 'Nothing' +        }; +      } +      if (that = it.match(/^'([\s\S]*)'$/)) { +        return { +          type: 'Just', +          value: that[1].replace(/\\'/g, "'") +        }; +      } else if (that = it.match(/^"([\s\S]*)"$/)) { +        return { +          type: 'Just', +          value: that[1].replace(/\\"/g, '"') +        }; +      } else { +        return { +          type: 'Just', +          value: it +        }; +      } +    } +  }; +  function castArray(node, type, options){ +    var typeOf, element; +    if (toString$.call(node).slice(8, -1) !== 'Array') { +      return { +        type: 'Nothing' +      }; +    } +    typeOf = type.of; +    return { +      type: 'Just', +      value: (function(){ +        var i$, ref$, len$, results$ = []; +        for (i$ = 0, len$ = (ref$ = node).length; i$ < len$; ++i$) { +          element = ref$[i$]; +          results$.push(typesCast(element, typeOf, options)); +        } +        return results$; +      }()) +    }; +  } +  function castTuple(node, type, options){ +    var result, i, i$, ref$, len$, types, cast; +    if (toString$.call(node).slice(8, -1) !== 'Array') { +      return { +        type: 'Nothing' +      }; +    } +    result = []; +    i = 0; +    for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) { +      types = ref$[i$]; +      cast = typesCast(node[i], types, options); +      if (toString$.call(cast).slice(8, -1) !== 'Undefined') { +        result.push(cast); +      } +      i++; +    } +    if (node.length <= i) { +      return { +        type: 'Just', +        value: result +      }; +    } else { +      return { +        type: 'Nothing' +      }; +    } +  } +  function castFields(node, type, options){ +    var typeOf, key, value; +    if (toString$.call(node).slice(8, -1) !== 'Object') { +      return { +        type: 'Nothing' +      }; +    } +    typeOf = type.of; +    return { +      type: 'Just', +      value: (function(){ +        var ref$, resultObj$ = {}; +        for (key in ref$ = node) { +          value = ref$[key]; +          resultObj$[typesCast(key, [{ +            type: 'String' +          }], options)] = typesCast(value, typeOf[key] || [{ +            type: '*' +          }], options); +        } +        return resultObj$; +      }()) +    }; +  } +  function typeCast(node, typeObj, options){ +    var type, structure, castFunc, ref$; +    type = typeObj.type, structure = typeObj.structure; +    if (type) { +      castFunc = ((ref$ = options.customTypes[type]) != null ? ref$.cast : void 8) || types[type]; +      if (!castFunc) { +        throw new Error("Type not defined: " + type + "."); +      } +      return castFunc(node, options, typesCast); +    } else { +      switch (structure) { +      case 'array': +        return castArray(node, typeObj, options); +      case 'tuple': +        return castTuple(node, typeObj, options); +      case 'fields': +        return castFields(node, typeObj, options); +      } +    } +  } +  function typesCast(node, types, options){ +    var i$, len$, type, ref$, valueType, value; +    for (i$ = 0, len$ = types.length; i$ < len$; ++i$) { +      type = types[i$]; +      ref$ = typeCast(node, type, options), valueType = ref$.type, value = ref$.value; +      if (valueType === 'Nothing') { +        continue; +      } +      if (parsedTypeCheck([type], value, { +        customTypes: options.customTypes +      })) { +        return value; +      } +    } +    throw new Error("Value " + JSON.stringify(node) + " does not type check against " + JSON.stringify(types) + "."); +  } +  module.exports = typesCast; +}).call(this); diff --git a/node_modules/levn/lib/coerce.js b/node_modules/levn/lib/coerce.js new file mode 100644 index 0000000..027b6da --- /dev/null +++ b/node_modules/levn/lib/coerce.js @@ -0,0 +1,285 @@ +// Generated by LiveScript 1.2.0 +(function(){ +  var parsedTypeCheck, types, toString$ = {}.toString; +  parsedTypeCheck = require('type-check').parsedTypeCheck; +  types = { +    '*': function(it){ +      switch (toString$.call(it).slice(8, -1)) { +      case 'Array': +        return coerceType(it, { +          type: 'Array' +        }); +      case 'Object': +        return coerceType(it, { +          type: 'Object' +        }); +      default: +        return { +          type: 'Just', +          value: coerceTypes(it, [ +            { +              type: 'Undefined' +            }, { +              type: 'Null' +            }, { +              type: 'NaN' +            }, { +              type: 'Boolean' +            }, { +              type: 'Number' +            }, { +              type: 'Date' +            }, { +              type: 'RegExp' +            }, { +              type: 'Array' +            }, { +              type: 'Object' +            }, { +              type: 'String' +            } +          ], { +            explicit: true +          }) +        }; +      } +    }, +    Undefined: function(it){ +      if (it === 'undefined' || it === void 8) { +        return { +          type: 'Just', +          value: void 8 +        }; +      } else { +        return { +          type: 'Nothing' +        }; +      } +    }, +    Null: function(it){ +      if (it === 'null') { +        return { +          type: 'Just', +          value: null +        }; +      } else { +        return { +          type: 'Nothing' +        }; +      } +    }, +    NaN: function(it){ +      if (it === 'NaN') { +        return { +          type: 'Just', +          value: NaN +        }; +      } else { +        return { +          type: 'Nothing' +        }; +      } +    }, +    Boolean: function(it){ +      if (it === 'true') { +        return { +          type: 'Just', +          value: true +        }; +      } else if (it === 'false') { +        return { +          type: 'Just', +          value: false +        }; +      } else { +        return { +          type: 'Nothing' +        }; +      } +    }, +    Number: function(it){ +      return { +        type: 'Just', +        value: +it +      }; +    }, +    Int: function(it){ +      return { +        type: 'Just', +        value: parseInt(it) +      }; +    }, +    Float: function(it){ +      return { +        type: 'Just', +        value: parseFloat(it) +      }; +    }, +    Date: function(value, options){ +      var that; +      if (that = /^\#(.*)\#$/.exec(value)) { +        return { +          type: 'Just', +          value: new Date(+that[1] || that[1]) +        }; +      } else if (options.explicit) { +        return { +          type: 'Nothing' +        }; +      } else { +        return { +          type: 'Just', +          value: new Date(+value || value) +        }; +      } +    }, +    RegExp: function(value, options){ +      var that; +      if (that = /^\/(.*)\/([gimy]*)$/.exec(value)) { +        return { +          type: 'Just', +          value: new RegExp(that[1], that[2]) +        }; +      } else if (options.explicit) { +        return { +          type: 'Nothing' +        }; +      } else { +        return { +          type: 'Just', +          value: new RegExp(value) +        }; +      } +    }, +    Array: function(it){ +      return coerceArray(it, { +        of: [{ +          type: '*' +        }] +      }); +    }, +    Object: function(it){ +      return coerceFields(it, { +        of: {} +      }); +    }, +    String: function(it){ +      var that; +      if (toString$.call(it).slice(8, -1) !== 'String') { +        return { +          type: 'Nothing' +        }; +      } +      if (that = it.match(/^'(.*)'$/)) { +        return { +          type: 'Just', +          value: that[1] +        }; +      } else if (that = it.match(/^"(.*)"$/)) { +        return { +          type: 'Just', +          value: that[1] +        }; +      } else { +        return { +          type: 'Just', +          value: it +        }; +      } +    } +  }; +  function coerceArray(node, type){ +    var typeOf, element; +    if (toString$.call(node).slice(8, -1) !== 'Array') { +      return { +        type: 'Nothing' +      }; +    } +    typeOf = type.of; +    return { +      type: 'Just', +      value: (function(){ +        var i$, ref$, len$, results$ = []; +        for (i$ = 0, len$ = (ref$ = node).length; i$ < len$; ++i$) { +          element = ref$[i$]; +          results$.push(coerceTypes(element, typeOf)); +        } +        return results$; +      }()) +    }; +  } +  function coerceTuple(node, type){ +    var result, i$, ref$, len$, i, types, that; +    if (toString$.call(node).slice(8, -1) !== 'Array') { +      return { +        type: 'Nothing' +      }; +    } +    result = []; +    for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) { +      i = i$; +      types = ref$[i$]; +      if (that = coerceTypes(node[i], types)) { +        result.push(that); +      } +    } +    return { +      type: 'Just', +      value: result +    }; +  } +  function coerceFields(node, type){ +    var typeOf, key, value; +    if (toString$.call(node).slice(8, -1) !== 'Object') { +      return { +        type: 'Nothing' +      }; +    } +    typeOf = type.of; +    return { +      type: 'Just', +      value: (function(){ +        var ref$, results$ = {}; +        for (key in ref$ = node) { +          value = ref$[key]; +          results$[key] = coerceTypes(value, typeOf[key] || [{ +            type: '*' +          }]); +        } +        return results$; +      }()) +    }; +  } +  function coerceType(node, typeObj, options){ +    var type, structure, coerceFunc; +    type = typeObj.type, structure = typeObj.structure; +    if (type) { +      coerceFunc = types[type]; +      return coerceFunc(node, options); +    } else { +      switch (structure) { +      case 'array': +        return coerceArray(node, typeObj); +      case 'tuple': +        return coerceTuple(node, typeObj); +      case 'fields': +        return coerceFields(node, typeObj); +      } +    } +  } +  function coerceTypes(node, types, options){ +    var i$, len$, type, ref$, valueType, value; +    for (i$ = 0, len$ = types.length; i$ < len$; ++i$) { +      type = types[i$]; +      ref$ = coerceType(node, type, options), valueType = ref$.type, value = ref$.value; +      if (valueType === 'Nothing') { +        continue; +      } +      if (parsedTypeCheck([type], value)) { +        return value; +      } +    } +    throw new Error("Value " + JSON.stringify(node) + " does not type check against " + JSON.stringify(types) + "."); +  } +  module.exports = coerceTypes; +}).call(this); diff --git a/node_modules/levn/lib/index.js b/node_modules/levn/lib/index.js new file mode 100644 index 0000000..4adae30 --- /dev/null +++ b/node_modules/levn/lib/index.js @@ -0,0 +1,22 @@ +// Generated by LiveScript 1.4.0 +(function(){ +  var parseString, cast, parseType, VERSION, parsedTypeParse, parse; +  parseString = require('./parse-string'); +  cast = require('./cast'); +  parseType = require('type-check').parseType; +  VERSION = '0.3.0'; +  parsedTypeParse = function(parsedType, string, options){ +    options == null && (options = {}); +    options.explicit == null && (options.explicit = false); +    options.customTypes == null && (options.customTypes = {}); +    return cast(parseString(parsedType, string, options), parsedType, options); +  }; +  parse = function(type, string, options){ +    return parsedTypeParse(parseType(type), string, options); +  }; +  module.exports = { +    VERSION: VERSION, +    parse: parse, +    parsedTypeParse: parsedTypeParse +  }; +}).call(this); diff --git a/node_modules/levn/lib/parse-string.js b/node_modules/levn/lib/parse-string.js new file mode 100644 index 0000000..d573975 --- /dev/null +++ b/node_modules/levn/lib/parse-string.js @@ -0,0 +1,113 @@ +// Generated by LiveScript 1.4.0 +(function(){ +  var reject, special, tokenRegex; +  reject = require('prelude-ls').reject; +  function consumeOp(tokens, op){ +    if (tokens[0] === op) { +      return tokens.shift(); +    } else { +      throw new Error("Expected '" + op + "', but got '" + tokens[0] + "' instead in " + JSON.stringify(tokens) + "."); +    } +  } +  function maybeConsumeOp(tokens, op){ +    if (tokens[0] === op) { +      return tokens.shift(); +    } +  } +  function consumeList(tokens, arg$, hasDelimiters){ +    var open, close, result, untilTest; +    open = arg$[0], close = arg$[1]; +    if (hasDelimiters) { +      consumeOp(tokens, open); +    } +    result = []; +    untilTest = "," + (hasDelimiters ? close : ''); +    while (tokens.length && (hasDelimiters && tokens[0] !== close)) { +      result.push(consumeElement(tokens, untilTest)); +      maybeConsumeOp(tokens, ','); +    } +    if (hasDelimiters) { +      consumeOp(tokens, close); +    } +    return result; +  } +  function consumeArray(tokens, hasDelimiters){ +    return consumeList(tokens, ['[', ']'], hasDelimiters); +  } +  function consumeTuple(tokens, hasDelimiters){ +    return consumeList(tokens, ['(', ')'], hasDelimiters); +  } +  function consumeFields(tokens, hasDelimiters){ +    var result, untilTest, key; +    if (hasDelimiters) { +      consumeOp(tokens, '{'); +    } +    result = {}; +    untilTest = "," + (hasDelimiters ? '}' : ''); +    while (tokens.length && (!hasDelimiters || tokens[0] !== '}')) { +      key = consumeValue(tokens, ':'); +      consumeOp(tokens, ':'); +      result[key] = consumeElement(tokens, untilTest); +      maybeConsumeOp(tokens, ','); +    } +    if (hasDelimiters) { +      consumeOp(tokens, '}'); +    } +    return result; +  } +  function consumeValue(tokens, untilTest){ +    var out; +    untilTest == null && (untilTest = ''); +    out = ''; +    while (tokens.length && -1 === untilTest.indexOf(tokens[0])) { +      out += tokens.shift(); +    } +    return out; +  } +  function consumeElement(tokens, untilTest){ +    switch (tokens[0]) { +    case '[': +      return consumeArray(tokens, true); +    case '(': +      return consumeTuple(tokens, true); +    case '{': +      return consumeFields(tokens, true); +    default: +      return consumeValue(tokens, untilTest); +    } +  } +  function consumeTopLevel(tokens, types, options){ +    var ref$, type, structure, origTokens, result, finalResult, x$, y$; +    ref$ = types[0], type = ref$.type, structure = ref$.structure; +    origTokens = tokens.concat(); +    if (!options.explicit && types.length === 1 && ((!type && structure) || (type === 'Array' || type === 'Object'))) { +      result = structure === 'array' || type === 'Array' +        ? consumeArray(tokens, tokens[0] === '[') +        : structure === 'tuple' +          ? consumeTuple(tokens, tokens[0] === '(') +          : consumeFields(tokens, tokens[0] === '{'); +      finalResult = tokens.length ? consumeElement(structure === 'array' || type === 'Array' +        ? (x$ = origTokens, x$.unshift('['), x$.push(']'), x$) +        : (y$ = origTokens, y$.unshift('('), y$.push(')'), y$)) : result; +    } else { +      finalResult = consumeElement(tokens); +    } +    return finalResult; +  } +  special = /\[\]\(\)}{:,/.source; +  tokenRegex = RegExp('("(?:\\\\"|[^"])*")|(\'(?:\\\\\'|[^\'])*\')|(/(?:\\\\/|[^/])*/[a-zA-Z]*)|(#.*#)|([' + special + '])|([^\\s' + special + '](?:\\s*[^\\s' + special + ']+)*)|\\s*'); +  module.exports = function(types, string, options){ +    var tokens, node; +    options == null && (options = {}); +    if (!options.explicit && types.length === 1 && types[0].type === 'String') { +      return "'" + string.replace(/\\'/g, "\\\\'") + "'"; +    } +    tokens = reject(not$, string.split(tokenRegex)); +    node = consumeTopLevel(tokens, types, options); +    if (!node) { +      throw new Error("Error parsing '" + string + "'."); +    } +    return node; +  }; +  function not$(x){ return !x; } +}).call(this); diff --git a/node_modules/levn/lib/parse.js b/node_modules/levn/lib/parse.js new file mode 100644 index 0000000..2beff0f --- /dev/null +++ b/node_modules/levn/lib/parse.js @@ -0,0 +1,102 @@ +// Generated by LiveScript 1.2.0 +(function(){ +  var reject, special, tokenRegex; +  reject = require('prelude-ls').reject; +  function consumeOp(tokens, op){ +    if (tokens[0] === op) { +      return tokens.shift(); +    } else { +      throw new Error("Expected '" + op + "', but got '" + tokens[0] + "' instead in " + JSON.stringify(tokens) + "."); +    } +  } +  function maybeConsumeOp(tokens, op){ +    if (tokens[0] === op) { +      return tokens.shift(); +    } +  } +  function consumeList(tokens, delimiters, hasDelimiters){ +    var result; +    if (hasDelimiters) { +      consumeOp(tokens, delimiters[0]); +    } +    result = []; +    while (tokens.length && tokens[0] !== delimiters[1]) { +      result.push(consumeElement(tokens)); +      maybeConsumeOp(tokens, ','); +    } +    if (hasDelimiters) { +      consumeOp(tokens, delimiters[1]); +    } +    return result; +  } +  function consumeArray(tokens, hasDelimiters){ +    return consumeList(tokens, ['[', ']'], hasDelimiters); +  } +  function consumeTuple(tokens, hasDelimiters){ +    return consumeList(tokens, ['(', ')'], hasDelimiters); +  } +  function consumeFields(tokens, hasDelimiters){ +    var result, key; +    if (hasDelimiters) { +      consumeOp(tokens, '{'); +    } +    result = {}; +    while (tokens.length && (!hasDelimiters || tokens[0] !== '}')) { +      key = tokens.shift(); +      consumeOp(tokens, ':'); +      result[key] = consumeElement(tokens); +      maybeConsumeOp(tokens, ','); +    } +    if (hasDelimiters) { +      consumeOp(tokens, '}'); +    } +    return result; +  } +  function consumeElement(tokens){ +    switch (tokens[0]) { +    case '[': +      return consumeArray(tokens, true); +    case '(': +      return consumeTuple(tokens, true); +    case '{': +      return consumeFields(tokens, true); +    default: +      return tokens.shift(); +    } +  } +  function consumeTopLevel(tokens, types){ +    var ref$, type, structure, origTokens, result, finalResult, x$, y$; +    ref$ = types[0], type = ref$.type, structure = ref$.structure; +    origTokens = tokens.concat(); +    if (types.length === 1 && (structure || (type === 'Array' || type === 'Object'))) { +      result = structure === 'array' || type === 'Array' +        ? consumeArray(tokens, tokens[0] === '[') +        : structure === 'tuple' +          ? consumeTuple(tokens, tokens[0] === '(') +          : consumeFields(tokens, tokens[0] === '{'); +      finalResult = tokens.length ? consumeElement(structure === 'array' || type === 'Array' +        ? (x$ = origTokens, x$.unshift('['), x$.push(']'), x$) +        : (y$ = origTokens, y$.unshift('('), y$.push(')'), y$)) : result; +    } else { +      finalResult = consumeElement(tokens); +    } +    if (tokens.length && origTokens.length) { +      throw new Error("Unable to parse " + JSON.stringify(origTokens) + " of type " + JSON.stringify(types) + "."); +    } else { +      return finalResult; +    } +  } +  special = /\[\]\(\)}{:,/.source; +  tokenRegex = RegExp('("(?:[^"]|\\\\")*")|(\'(?:[^\']|\\\\\')*\')|(#.*#)|(/(?:\\\\/|[^/])*/[gimy]*)|([' + special + '])|([^\\s' + special + ']+)|\\s*'); +  module.exports = function(string, types){ +    var tokens, node; +    tokens = reject(function(it){ +      return !it || /^\s+$/.test(it); +    }, string.split(tokenRegex)); +    node = consumeTopLevel(tokens, types); +    if (!node) { +      throw new Error("Error parsing '" + string + "'."); +    } +    return node; +  }; +}).call(this);  | 
