[Pkg-javascript-commits] [node-levn] 05/10: New upstream version 0.3.0+dfsg
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Thu Oct 13 06:09:00 UTC 2016
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository node-levn.
commit 08c5ee56a9000ae826b3078146c60e0c2e79f12a
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Tue Oct 11 17:52:56 2016 +0530
New upstream version 0.3.0+dfsg
---
lib/cast.js | 298 ----------------------------------------------------
lib/coerce.js | 285 -------------------------------------------------
lib/index.js | 22 ----
lib/parse-string.js | 113 --------------------
lib/parse.js | 102 ------------------
package.json | 47 ---------
6 files changed, 867 deletions(-)
diff --git a/lib/cast.js b/lib/cast.js
deleted file mode 100644
index 411e29d..0000000
--- a/lib/cast.js
+++ /dev/null
@@ -1,298 +0,0 @@
-// 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/lib/coerce.js b/lib/coerce.js
deleted file mode 100644
index 027b6da..0000000
--- a/lib/coerce.js
+++ /dev/null
@@ -1,285 +0,0 @@
-// 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/lib/index.js b/lib/index.js
deleted file mode 100644
index 4adae30..0000000
--- a/lib/index.js
+++ /dev/null
@@ -1,22 +0,0 @@
-// 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/lib/parse-string.js b/lib/parse-string.js
deleted file mode 100644
index d573975..0000000
--- a/lib/parse-string.js
+++ /dev/null
@@ -1,113 +0,0 @@
-// 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/lib/parse.js b/lib/parse.js
deleted file mode 100644
index 2beff0f..0000000
--- a/lib/parse.js
+++ /dev/null
@@ -1,102 +0,0 @@
-// 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);
diff --git a/package.json b/package.json
deleted file mode 100644
index 56dfbc4..0000000
--- a/package.json
+++ /dev/null
@@ -1,47 +0,0 @@
-{
- "name": "levn",
- "version": "0.3.0",
- "author": "George Zahariev <z at georgezahariev.com>",
- "description": "Light ECMAScript (JavaScript) Value Notation - human written, concise, typed, flexible",
- "homepage": "https://github.com/gkz/levn",
- "keywords": [
- "levn",
- "light",
- "ecmascript",
- "value",
- "notation",
- "json",
- "typed",
- "human",
- "concise",
- "typed",
- "flexible"
- ],
- "files": [
- "lib",
- "README.md",
- "LICENSE"
- ],
- "main": "./lib/",
- "bugs": "https://github.com/gkz/levn/issues",
- "license": "MIT",
- "engines": {
- "node": ">= 0.8.0"
- },
- "repository": {
- "type": "git",
- "url": "git://github.com/gkz/levn.git"
- },
- "scripts": {
- "test": "make test"
- },
- "dependencies": {
- "prelude-ls": "~1.1.2",
- "type-check": "~0.3.2"
- },
- "devDependencies": {
- "livescript": "~1.4.0",
- "mocha": "~2.3.4",
- "istanbul": "~0.4.1"
- }
-}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-levn.git
More information about the Pkg-javascript-commits
mailing list