feature(client) es2015-ify

This commit is contained in:
coderaiser 2017-02-09 14:44:27 +02:00
parent 8944d1522e
commit 6a5b254a75
79 changed files with 7365 additions and 9347 deletions

View file

@ -1,32 +0,0 @@
{
"name": "currify",
"description": "translate the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single or more arguments",
"homepage": "https://github.com/coderaiser/currify",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"main": "lib/currify.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"curry",
"functional"
],
"license": "MIT",
"ignore": [
"**/.*",
"test"
],
"version": "2.0.3",
"_release": "2.0.3",
"_resolution": {
"type": "version",
"tag": "v2.0.3",
"commit": "be9ab0b0f7b8e685da89321df384ac902fa3c587"
},
"_source": "https://github.com/coderaiser/currify.git",
"_target": "2.0.3",
"_originalSource": "currify"
}

View file

@ -1,34 +0,0 @@
2016.12.05, v2.0.3
fix:
- (currify) bundle: empty currify in dist
2016.11.23, v2.0.2
fix:
- (currify) when to much function.length use default
2016.11.23, v2.0.1
fix:
- (currify) add support of 4 and 5 arguments
2016.11.23, v2.0.0
feature:
- (travis) node_js: v6, v7
- (currify) fn.length in curried functions
- (package) scripts: coverage
- (gitignore) *.swp
- (currify) es2015-ify
- (package) redrun v5.0.0
- (package) redrun v4.0.0
- (package) npm-run-all -> redrun
- (package) jscs v3.0.3
- (license) add
- (gitignore) npm-debug.log -> npm-debug.log*
- (package) browserify v13.0.0

View file

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) coderaiser
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,48 +0,0 @@
# Currify [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL]
Translate the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single or more arguments.
## Install
```
npm i currify --save
```
## How to use?
```js
const currify = require('currify');
const mean = (a, b, c) => (a + b) / c;
const mean1 = currify(mean, 1);
const mean2 = mean1(2);
mean2(2);
// returns
1.5
```
## Environments
In old `node.js` environments that not fully supports `es2015`, `currify` could be used with:
```js
var currify = require('currify/legacy');
```
## Related
- [zames](https://github.com/coderaiser/zames "zames") - converts callback-based functions to Promises and apply currying to arguments
## License
MIT
[NPMIMGURL]: https://img.shields.io/npm/v/currify.svg?style=flat
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/currify/master.svg?style=flat
[DependencyStatusIMGURL]: https://img.shields.io/gemnasium/coderaiser/currify.svg?style=flat
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[NPMURL]: https://npmjs.org/package/currify "npm"
[BuildStatusURL]: https://travis-ci.org/coderaiser/currify "Build Status"
[DependencyStatusURL]: https://gemnasium.com/coderaiser/currify "Dependency Status"
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"

View file

@ -1,22 +0,0 @@
{
"name": "currify",
"description": "translate the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single or more arguments",
"homepage": "https://github.com/coderaiser/currify",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"main": "lib/currify.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"curry",
"functional"
],
"license": "MIT",
"ignore": [
"**/.*",
"test"
]
}

View file

@ -1 +0,0 @@
!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.currify=r()}}(function(){return function r(n,e,t){function o(f,u){if(!e[f]){if(!n[f]){var c="function"==typeof require&&require;if(!u&&c)return c(f,!0);if(i)return i(f,!0);var l=new Error("Cannot find module '"+f+"'");throw l.code="MODULE_NOT_FOUND",l}var p=e[f]={exports:{}};n[f][0].call(p.exports,function(r){var e=n[f][1][r];return o(e?e:r)},p,p.exports,r,n,e,t)}return e[f].exports}for(var i="function"==typeof require&&require,f=0;f<t.length;f++)o(t[f]);return o}({currify:[function(r,n,e){"use strict";function t(r){if(Array.isArray(r)){for(var n=0,e=Array(r.length);n<r.length;n++)e[n]=r[n];return e}return Array.from(r)}function o(r){if("function"!=typeof r)throw Error("fn should be function!")}var i=function(r){return[].slice.call(r,1)},f=function(r){return[function(n){return r.apply(void 0,arguments)},function(n,e){return r.apply(void 0,arguments)},function(n,e,t){return r.apply(void 0,arguments)},function(n,e,t,o){return r.apply(void 0,arguments)},function(n,e,t,o,i){return r.apply(void 0,arguments)}]};n.exports=function r(n){o(n);var e=i(arguments);if(e.length>=n.length)return n.apply(void 0,t(e));var u=function(){return r.apply(void 0,[n].concat(t(e),Array.prototype.slice.call(arguments)))},c=n.length-arguments.length,l=f(u)[c];return l||u}},{}]},{},["currify"])("currify")});

View file

@ -1,44 +0,0 @@
'use strict';
const tail = list => [].slice.call(list, 1);
const f = (fn) => [
function(a) {
return fn(...arguments);
},
function(a, b) {
return fn(...arguments);
},
function(a, b, c) {
return fn(...arguments);
},
function(a, b, c, d) {
return fn(...arguments);
},
function(a, b, c, d, e) {
return fn(...arguments);
}
];
module.exports = function currify(fn) {
check(fn);
const args = tail(arguments);
if (args.length >= fn.length)
return fn(...args);
const again = function() {
return currify(...[fn, ...args, ...arguments]);
};
const count = fn.length - arguments.length;
const func = f(again)[count];
return func || again;
}
function check(fn) {
if (typeof fn !== 'function')
throw Error('fn should be function!');
}

View file

@ -1,53 +0,0 @@
{
"name": "currify",
"version": "2.0.3",
"description": "translate the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single or more arguments",
"main": "lib/currify.js",
"scripts": {
"test": "tape test/*.js",
"coverage": "nyc npm test",
"lint": "eslint lib test",
"build": "redrun clean 6to5 legacy:* bundle bundle minify",
"minify": "minify dist/currify.js > dist/currify.min.js",
"6to5": "babel -d legacy/lib lib",
"wisdom": "npm run build",
"clean": "rimraf dist/* legacy/*",
"bundle:base": "browserify -s currify --ng false",
"bundle": "npm run bundle:base -- -r ./legacy/lib/currify.js:currify ./legacy/lib/currify.js -o dist/currify.js",
"watcher": "nodemon -w test -w lib --exec",
"watch:test": "npm run watcher -- npm test",
"watch:lint": "npm run watcher -- 'npm run lint'",
"watch:tape": "nodemon -w test -w lib --exec tape",
"watch:coverage:base": "npm run watcher -- nyc npm test",
"watch:coverage:tape": "npm run watcher -- nyc tape",
"watch:coverage": "bin/redrun.js watch:coverage:base",
"legacy:index": "echo \"module.exports = require('./lib/currify');\" > legacy/index.js"
},
"repository": {
"type": "git",
"url": "git://github.com/coderaiser/currify.git"
},
"keywords": [
"currify",
"partial",
"functional"
],
"author": "coderaiser <mnemonic.enemy@gmail.com> (http://coderaiser.github.io/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/coderaiser/currify/issues"
},
"homepage": "https://github.com/coderaiser/currify",
"devDependencies": {
"babel-cli": "^6.1.1",
"babel-preset-es2015": "^6.0.15",
"browserify": "^13.0.0",
"eslint": "^3.10.2",
"minify": "^2.0.13",
"nodemon": "^1.11.0",
"nyc": "^10.0.0",
"redrun": "^5.0.1",
"rimraf": "^2.4.3",
"tape": "^4.2.0"
}
}

View file

@ -1,34 +0,0 @@
{
"name": "execon",
"version": "1.2.9",
"homepage": "https://github.com/coderaiser/execon",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"description": "Patterns of function calls",
"main": "lib/exec.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"exec"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"_release": "1.2.9",
"_resolution": {
"type": "version",
"tag": "v1.2.9",
"commit": "b71d2c60651f957486301e10462aab80a0f62ee1"
},
"_source": "git://github.com/coderaiser/execon.git",
"_target": "~1.2.8",
"_originalSource": "execon"
}

View file

@ -1,86 +0,0 @@
2015.10.23, v1.2.9
fix:
- (exec) parallel throw: add " "
2015.10.21, v1.2.8
fix:
- (exec) with do not return value
feature:
- (travis) add
- (gitignore) add
2015.10.01, v1.2.7
fix:
- (exec) with: concat arguments
2015.10.01, v1.2.6
feature:
- (exec) with: bind.apply -> function apply
2015.07.21, v1.2.5
fix:
- (exec) eachSeries
2015.07.21, v1.2.4
fix:
- (exec) each, eachSeries
2015.07.21, v1.2.3
fix:
- (exec) each, eachSeries: call callback when !listeners.length
2015.06.05, v1.2.2
feature:
- (exec) with: callback.bind -> bind.apply
2015.06.05, v1.2.1
feature:
- (exec) exec.with: arguments[0] -> slice.call(arguments)
2015.06.03, v1.2.0
feature:
- (exec) add each, eachSeries
- (exec) series: rm getType call
2015.01.28, v1.1.1
feature:
- (exec) scope -> global
- (bower) add
- (package) node-execon -> execon
- (package) v1.1.0
- (execon) series: add callback
2015.01.15, v1.1.0
feature:
- (execon) series: add callback
2014.11.24, v1.0.1
fix:
- (package) check -> exec

View file

@ -1,20 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014-2015 coderaiser
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,154 +0,0 @@
# Execon [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![BuildStatusIMGURL]][BuildStatusURL]
Patterns of function calls.
## Install
![NPM_INFO][NPM_INFO_IMG]
```
npm i execon --save
# or
bower i execon --save
```
## Api
```js
var exec = require('execon');
```
### exec
Check is parameter is function, if it's - executes it with given parameters
Was:
```js
function(callback, p1, p2, pN) {
if (typeof callback === 'function')
callback(p1, p2, pN);
}
```
Now
```js
function(callback, p1, p2, pN) {
exec(callback, p1, p2, pN);
}
```
or just
```js
exec.ret(callback, p1, p2, pN);
```
### exec.if
Conditional execution one of two functions
Preconditions:
```js
function one() {
console.log(1);
}
function two(callback) {
setTimeout(callback, 1000);
}
```
Before:
```js
if (2 > 3)
one();
else
two(one);
```
After:
```js
exec.if(2 > 3, one, two);
```
### exec.parallel
if a you need a couple async operation do same work, and then call callback, this function for you.
**Node.js example**.
```js
var fs = require('fs'),
Util = require('execon');
exec.parallel([
function(callback) {
fs.readFile('file1', callback);
},
function(callback) {
fs.readFile('file2', callback);
}
], function(error, data1, data2) {
if (error)
console.log(error)
else
console.log(data1, data2);
});
```
**Vanilla js example.**
```js
var ONE_SECOND = 1000,
TWO_SECONDS = 2000,
func = function(time, str, callback) {
setTimeout(function() {
console.log(str);
callback(null, str);
}, time);
},
func1 = func.bind(null, TWO_SECONDS, 'first'),
func2 = func.bind(null, ONE_SECOND, 'second');
exec.parallel([func1, func2], function(error, str1, str2) {
console.log(str1, str2);
});
```
### exec.series
executes functions one-by-one
```js
function one(callback){
setTimeout(function() {
console.log(1)
callback();
}, 1000);
}
function two(callback) {
console.log(2);
callback();
}
exec.series([one, two], function(error) {
console.log(error || 'done');
});
```
## License
MIT
[NPM_INFO_IMG]: https://nodei.co/npm/execon.png?downloads=true&&stars&&downloadRank "npm install rendy"
[NPMIMGURL]: https://img.shields.io/npm/v/execon.svg?style=flat
[DependencyStatusIMGURL]: https://img.shields.io/gemnasium/coderaiser/execon.svg?style=flat
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[NPMURL]: https://npmjs.org/package/execon "npm"
[BuildStatusURL]: https://travis-ci.org/coderaiser/execon "Build Status"
[DependencyStatusURL]: https://gemnasium.com/coderaiser/execon "Dependency Status"
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/execon/master.svg?style=flat
[BuildStatusURL]: https://travis-ci.org/coderaiser/execon "Build Status"

View file

@ -1,25 +0,0 @@
{
"name": "execon",
"version": "1.2.9",
"homepage": "https://github.com/coderaiser/execon",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"description": "Patterns of function calls",
"main": "lib/exec.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"exec"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}

View file

@ -1,244 +0,0 @@
(function(global) {
'use strict';
if (typeof module === 'object' && module.exports)
module.exports = new ExecProto();
else
global.exec = new ExecProto();
function ExecProto() {
var slice = Array.prototype.slice,
/**
* function do save exec of function
* @param callback
* @param arg1
* ...
* @param argN
*/
exec = function(callback) {
var ret,
isFunc = typeof callback === 'function',
args = slice.call(arguments, 1);
if (isFunc)
ret = callback.apply(null, args);
return ret;
};
/*
* return function that calls callback with arguments
*/
exec.with = function(callback) {
var slice = Array.prototype.slice,
args = slice.call(arguments, 1);
return function() {
var array = slice.call(arguments),
all = args.concat(array);
return callback.apply(null, all);
};
};
/**
* return save exec function
* @param callback
*/
exec.ret = function() {
var result,
args = slice.call(arguments);
args.unshift(exec);
result = exec.with.apply(null, args);
return result;
};
/**
* function do conditional save exec of function
* @param condition
* @param callback
* @param func
*/
exec.if = function(condition, callback, func) {
var ret;
if (condition)
exec(callback);
else
exec(func, callback);
return ret;
};
/**
* exec function if it exist in object
*
* @param obj
* @param name
* @param arg
*/
exec.ifExist = function(obj, name, arg) {
var ret,
func = obj && obj[name];
if (func)
func = func.apply(obj, arg);
return ret;
};
exec.parallel = function(funcs, callback) {
var ERROR = 'could not be empty!',
keys = [],
callbackWas = false,
arr = [],
obj = {},
count = 0,
countFuncs = 0,
type = getType(funcs);
if (!funcs)
throw Error('funcs ' + ERROR);
if (!callback)
throw Error('callback ' + ERROR);
switch(type) {
case 'array':
countFuncs = funcs.length;
funcs.forEach(function(func, num) {
exec(func, function() {
checkFunc(num, arguments);
});
});
break;
case 'object':
keys = Object.keys(funcs);
countFuncs = keys.length;
keys.forEach(function(name) {
var func = funcs[name];
exec(func, function() {
checkFunc(name, arguments, obj);
});
});
break;
}
function checkFunc(num, data) {
var args = slice.call(data, 1),
isLast = false,
error = data[0],
length = args.length;
++count;
isLast = count === countFuncs;
if (!error)
if (length >= 2)
arr[num] = args;
else
arr[num] = args[0];
if (!callbackWas && (error || isLast)) {
callbackWas = true;
if (type === 'array')
callback.apply(null, [error].concat(arr));
else
callback(error, arr);
}
}
};
/**
* load functions thrue callbacks one-by-one
* @param funcs {Array} - array of functions
*/
exec.series = function(funcs, callback) {
var fn,
i = funcs.length,
check = function(error) {
var done;
--i;
if (!i || error) {
done = true;
exec(callback, error);
}
return done;
};
if (!Array.isArray(funcs))
throw Error('funcs should be array!');
fn = funcs.shift();
exec(fn, function(error) {
if (!check(error))
exec.series(funcs, callback);
});
};
exec.each = function(array, iterator, callback) {
var listeners = array.map(function(item) {
return iterator.bind(null, item);
});
if (!listeners.length)
callback();
else
exec.parallel(listeners, callback);
};
exec.eachSeries = function(array, iterator, callback) {
var listeners = array.map(function(item) {
return iterator.bind(null, item);
});
if (typeof callback !== 'function')
throw Error('callback should be function');
if (!listeners.length)
callback();
else
exec.series(listeners, callback);
};
/**
* function execute param function in
* try...catch block
*
* @param callback
*/
exec.try = function(callback) {
var ret;
try {
ret = callback();
} catch(error) {
ret = error;
}
return ret;
};
function getType(variable) {
var regExp = new RegExp('\\s([a-zA-Z]+)'),
str = {}.toString.call(variable),
typeBig = str.match(regExp)[1],
result = typeBig.toLowerCase();
return result;
}
return exec;
}
})(this);

View file

@ -1,23 +0,0 @@
{
"name": "execon",
"version": "1.2.9",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
"description": "Patterns of function calls",
"homepage": "http://github.com/coderaiser/execon",
"scripts": {
"test": "tape test/*.js"
},
"repository": {
"type": "git",
"url": "git://github.com/coderaiser/execon.git"
},
"dependencies": {},
"license": "MIT",
"engines": {
"node": ">=0.8"
},
"main": "lib/exec.js",
"devDependencies": {
"tape": "~4.2.1"
}
}

View file

@ -1,36 +0,0 @@
{
"name": "format-io",
"version": "0.9.6",
"homepage": "https://github.com/coderaiser/format-io",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"description": "Format size, permissions, etc",
"main": "lib/format.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"format",
"size",
"permissions"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"_release": "0.9.6",
"_resolution": {
"type": "version",
"tag": "v0.9.6",
"commit": "3381e500de22cc60a25a4049589c377198f8cc57"
},
"_source": "git://github.com/coderaiser/format-io.git",
"_target": "~0.9.6",
"_originalSource": "format-io"
}

View file

@ -1,6 +0,0 @@
2015.02.18, v0.9.6
feature:
- (bower) add
- (format) scope -> global

View file

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014 coderaiser
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,49 +0,0 @@
# Format
Library for format size, permissions, etc.
# How to use?
Format could be used in browser or node.
In browser:
```js
<script src='lib/format.js'></script>
```
In node:
```js
var Format = require('format-io');
```
# API
## size
```js
var size = 1024 * 1024 * 5,
sizeStr = Format.size(size);
//'5.00mb'
```
## permissions.symbolic
```js
var perm = '00777',
permStr = Format.permissions.symbolic(perm);
//'rwx rwx rwx
```
## permissions.numeric
```js
var perm = 'rwx rwx rwx',
permNum = Format.permissions.numeric(perm);
//'00777'
```
# License
MIT

View file

@ -1,27 +0,0 @@
{
"name": "format-io",
"version": "0.9.6",
"homepage": "https://github.com/coderaiser/format-io",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"description": "Format size, permissions, etc",
"main": "lib/format.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"format",
"size",
"permissions"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}

View file

@ -1,163 +0,0 @@
(function(global) {
'use strict';
if (typeof module === 'object' && module.exports)
module.exports = new FormatProto();
else
global.Format = new FormatProto();
function FormatProto() {
this.addSlashToEnd = function(path) {
var length, isSlash;
if (path) {
length = path.length - 1;
isSlash = path[length] === '/';
if (!isSlash)
path += '/';
}
return path;
};
/** Функция получает короткие размеры
* конвертируя байт в килобайты, мегабойты,
* гигайбайты и терабайты
* @pSize - размер в байтах
*/
this.size = function(size) {
var isNumber = typeof size === 'number',
l1KB = 1024,
l1MB = l1KB * l1KB,
l1GB = l1MB * l1KB,
l1TB = l1GB * l1KB,
l1PB = l1TB * l1KB;
if (isNumber) {
if (size < l1KB) size = size + 'b';
else if (size < l1MB) size = (size / l1KB).toFixed(2) + 'kb';
else if (size < l1GB) size = (size / l1MB).toFixed(2) + 'mb';
else if (size < l1TB) size = (size / l1GB).toFixed(2) + 'gb';
else if (size < l1PB) size = (size / l1TB).toFixed(2) + 'tb';
else size = (size / l1PB).toFixed(2) + 'pb';
}
return size;
};
/**
* Функция переводит права из цыфрового вида в символьный
* @param perms - строка с правами доступа
* к файлу в 8-миричной системе
*/
this.permissions = {
symbolic: function(perms) {
var type, owner, group, all,
is = typeof perms !== undefined,
permsStr = '',
permissions = '';
/*
S_IRUSR 0000400 protection: readable by owner
S_IWUSR 0000200 writable by owner
S_IXUSR 0000100 executable by owner
S_IRGRP 0000040 readable by group
S_IWGRP 0000020 writable by group
S_IXGRP 0000010 executable by group
S_IROTH 0000004 readable by all
S_IWOTH 0000002 writable by all
S_IXOTH 0000001 executable by all
*/
if (is) {
permsStr = perms.toString();
/* тип файла */
type = permsStr.charAt(0);
switch (type - 0) {
case 1: /* обычный файл */
type = '-';
break;
case 2: /* байт-ориентированное (символьное) устройство*/
type = 'c';
break;
case 4: /* каталог */
type = 'd';
break;
default:
type = '-';
}
/* оставляем последние 3 символа*/
if (permsStr.length > 5)
permsStr = permsStr.substr(3);
else
permsStr = permsStr.substr(2);
/* Рекомендации гугла советуют вместо string[3]
* использовать string.charAt(3)
*/
/*
http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=Standards_features#Standards_features
Always preferred over non-standards featuresFor
maximum portability and compatibility, always
prefer standards features over non-standards
features (e.g., string.charAt(3) over string[3]
and element access with DOM functions instead
of using an application-specific shorthand).
*/
/* Переводим в двоичную систему */
owner = (permsStr[0] - 0).toString(2),
group = (permsStr[1] - 0).toString(2),
all = (permsStr[2] - 0).toString(2),
/* переводим в символьную систему*/
permissions =
(owner[0] - 0 > 0 ? 'r' : '-') +
(owner[1] - 0 > 0 ? 'w' : '-') +
(owner[2] - 0 > 0 ? 'x' : '-') +
' ' +
(group[0] - 0 > 0 ? 'r' : '-') +
(group[1] - 0 > 0 ? 'w' : '-') +
(group[2] - 0 > 0 ? 'x' : '-') +
' ' +
(all[0] - 0 > 0 ? 'r' : '-') +
(all[1] - 0 > 0 ? 'w' : '-') +
(all[2] - 0 > 0 ? 'x' : '-');
}
return permissions;
},
/**
* Функция конвертирует права доступа к файлам из символьного вида
* в цыфровой
*/
numeric: function(perms) {
var owner, group, all,
length = perms && perms.length === 11;
if (length) {
owner = (perms[0] === 'r' ? 4 : 0) +
(perms[1] === 'w' ? 2 : 0) +
(perms[2] === 'x' ? 1 : 0),
group = (perms[4] === 'r' ? 4 : 0) +
(perms[5] === 'w' ? 2 : 0) +
(perms[6] === 'x' ? 1 : 0),
all = (perms[8] === 'r' ? 4 : 0) +
(perms[9] === 'w' ? 2 : 0) +
(perms[10] === 'x' ? 1 : 0);
/* добавляем 2 цифры до 5 */
perms = '00' + owner + group + all;
}
return perms;
}
};
}
})(this);

View file

@ -1,22 +0,0 @@
{
"name": "format-io",
"version": "0.9.6",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
"description": "Format size, permissions, etc",
"homepage": "http://github.com/coderaiser/format-io",
"repository": {
"type": "git",
"url": "git://github.com/coderaiser/format-io.git"
},
"keywords": [
"format",
"size",
"permissions"
],
"dependencies": {},
"license": "MIT",
"engines": {
"node": ">=0.4.x"
},
"main": "lib/format.js"
}

View file

@ -1,35 +0,0 @@
{
"name": "itype",
"description": "Improved type check",
"main": "dist/itype.js",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)"
],
"license": "MIT",
"keywords": [
"type",
"string",
"array",
"object",
"boolean",
"null",
"undefined",
"check"
],
"homepage": "https://github.com/coderaiser/itype",
"ignore": [
".*",
"test",
"lib"
],
"version": "2.0.3",
"_release": "2.0.3",
"_resolution": {
"type": "version",
"tag": "v2.0.3",
"commit": "ec7f35bfdc6f9078d4e4792dd347bf98dd2f8ccc"
},
"_source": "https://github.com/coderaiser/itype.git",
"_target": "2.0.3",
"_originalSource": "itype"
}

View file

@ -1,35 +0,0 @@
2016.12.28, v2.0.3
fix:
- (bower) main
2016.12.28, v2.0.2
feature:
- (bower) ignore: add ".*"
2016.12.28, v2.0.1
feature:
- (bower) add
2016.12.28, v2.0.0
feature:
- (itype) add browser support
2015.01.30, v1.0.2
feature:
- (type) change format of regexp
2014.12.22, v1.0.1
feature:
- (itype) add null

View file

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014 coderaiser
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,52 +0,0 @@
# iType [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
Improved type check.
## Install
```
npm i itype --save
```
## How to use?
```js
var itype = require('itype');
console.og(itype.string('hello'))
// returns
true
console.log(itype('world'));
// returns
'string'
console.log(itype.array([1, 2]));
// returns
true
```
## Environments
In old `node.js` environments that not fully supports `es2015`, `itype` could be used with:
```js
var itype = require('itype/legacy');
```
## License
MIT
[NPMIMGURL]: https://img.shields.io/npm/v/itype.svg?style=flat
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/itype/master.svg?style=flat
[DependencyStatusIMGURL]: https://img.shields.io/gemnasium/coderaiser/itype.svg?style=flat
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[NPMURL]: https://npmjs.org/package/itype "npm"
[BuildStatusURL]: https://travis-ci.org/coderaiser/itype "Build Status"
[DependencyStatusURL]: https://gemnasium.com/coderaiser/itype "Dependency Status"
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
[CoverageURL]: https://coveralls.io/github/coderaiser/itype?branch=master
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/itype/badge.svg?branch=master&service=github

View file

@ -1,25 +0,0 @@
{
"name": "itype",
"description": "Improved type check",
"main": "dist/itype.js",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)"
],
"license": "MIT",
"keywords": [
"type",
"string",
"array",
"object",
"boolean",
"null",
"undefined",
"check"
],
"homepage": "https://github.com/coderaiser/itype",
"ignore": [
".*",
"test",
"lib"
]
}

View file

@ -1,49 +0,0 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.itype = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"itype":[function(require,module,exports){
'use strict';
module.exports = new TypeProto();
function TypeProto() {
/**
* get type of variable
*
* @param variable
*/
function type(variable) {
var regExp = /\s([a-zA-Z]+)/;
var str = {}.toString.call(variable);
var typeBig = str.match(regExp)[1];
var result = typeBig.toLowerCase();
return result;
}
/**
* functions check is variable is type of name
*
* @param variable
*/
function typeOf(name, variable) {
return type(variable) === name;
}
function typeOfSimple(name, variable) {
return typeof variable === name;
}
['arrayBuffer', 'file', 'array', 'object']
.forEach(function (name) {
type[name] = typeOf.bind(null, name);
});
['null', 'string', 'undefined', 'boolean', 'number', 'function']
.forEach(function (name) {
type[name] = typeOfSimple.bind(null, name);
});
return type;
}
},{}]},{},["itype"])("itype")
});

View file

@ -1 +0,0 @@
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.itype=e()}}(function(){return function e(n,r,t){function o(i,u){if(!r[i]){if(!n[i]){var c="function"==typeof require&&require;if(!u&&c)return c(i,!0);if(f)return f(i,!0);var l=new Error("Cannot find module '"+i+"'");throw l.code="MODULE_NOT_FOUND",l}var a=r[i]={exports:{}};n[i][0].call(a.exports,function(e){var r=n[i][1][e];return o(r?r:e)},a,a.exports,e,n,r,t)}return r[i].exports}for(var f="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({itype:[function(e,n,r){"use strict";function t(){function e(e){var n=/\s([a-zA-Z]+)/,r={}.toString.call(e),t=r.match(n)[1],o=t.toLowerCase();return o}function n(n,r){return e(r)===n}function r(e,n){return typeof n===e}return["arrayBuffer","file","array","object"].forEach(function(r){e[r]=n.bind(null,r)}),["null","string","undefined","boolean","number","function"].forEach(function(n){e[n]=r.bind(null,n)}),e}n.exports=new t},{}]},{},["itype"])("itype")});

View file

@ -1,53 +0,0 @@
{
"name": "itype",
"version": "2.0.3",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
"description": "Improved type check",
"main": "lib/itype.js",
"repository": {
"type": "git",
"url": "git://github.com/coderaiser/itype.git"
},
"keywords": [
"type",
"string",
"array",
"object",
"boolean",
"null",
"undefined",
"check"
],
"scripts": {
"test": "tape test/*.js",
"watcher": "nodemon -w test -w lib --exec",
"watch:test": "npm run watcher -- npm test",
"watch:coverage": "npm run watcher -- npm run coverage",
"lint": "eslint lib test",
"build": "redrun clean init 6to5 legacy:* bundle minify",
"init": "mkdirp dist legacy",
"minify": "minify dist/itype.js > dist/itype.min.js",
"wisdom": "npm run build",
"clean": "rimraf legacy dist",
"bundle:base": "browserify -s itype --ng false",
"bundle": "npm run bundle:base -- -r ./legacy/lib/itype.js:itype ./legacy/lib/itype.js -o dist/itype.js",
"coverage": "nyc npm test",
"report": "nyc report --reporter=text-lcov | coveralls",
"6to5": "buble lib -o legacy/lib",
"legacy:index": "echo \"module.exports = require('./lib/itype');\" > legacy/index.js"
},
"dependencies": {},
"license": "MIT",
"devDependencies": {
"browserify": "^13.0.0",
"buble": "^0.15.1",
"coveralls": "^2.11.9",
"eslint": "^3.10.2",
"minify": "^2.0.5",
"mkdirp": "^0.5.1",
"nodemon": "^1.11.0",
"nyc": "^10.0.0",
"redrun": "^5.0.1",
"tape": "^4.5.1"
}
}

View file

@ -1,34 +0,0 @@
{
"name": "jonny",
"version": "1.0.1",
"homepage": "https://github.com/coderaiser/jonny",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"description": "work with json without exaptions",
"main": "lib/jonny.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"json",
"try"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"modules"
],
"dependencies": {},
"_release": "1.0.1",
"_resolution": {
"type": "version",
"tag": "v1.0.1",
"commit": "b8909d33db868af9797c95881891c5d432209f1a"
},
"_source": "https://github.com/coderaiser/jonny.git",
"_target": "1.0.1",
"_originalSource": "jonny"
}

View file

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2015 coderaiser
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,26 +0,0 @@
# Jonny
Work with json without exeptions.
## Install
```
npm i jonny --save
```
## How to use?
```js
var jonny = require('jonny'),
obj = jonny.parse('{ "hello": "world" }');
console.log(jonny.stringify(obj, 0, 4));
// results
// "{
// "hello": "world"
// }"
```
## License
MIT

View file

@ -1,26 +0,0 @@
{
"name": "jonny",
"version": "1.0.0",
"homepage": "https://github.com/coderaiser/jonny",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"description": "work with json without exaptions",
"main": "lib/jonny.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"json",
"try"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"modules"
],
"dependencies": {
}
}

View file

@ -1,45 +0,0 @@
(function(global) {
'use strict';
if (typeof module !== 'undefined' && module.exports)
module.exports = new Jonny();
else
global.jonny = new Jonny();
function Jonny() {
this.parse = function() {
var ret,
args = arguments;
tryCatch(function() {
ret = JSON.parse.apply(JSON, args);
});
return ret;
};
this.stringify = function() {
var ret,
args = arguments;
tryCatch(function() {
ret = JSON.stringify.apply(JSON, args);
});
return ret;
};
function tryCatch(fn) {
var error;
try {
fn();
} catch(e) {
error = e;
}
return error;
}
}
})(this);

View file

@ -1,27 +0,0 @@
{
"name": "jonny",
"version": "1.0.0",
"description": "work with json without exaptions",
"main": "lib/jonny.js",
"dependencies": {
"diff-match-patch": "~1.0.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git://github.com/coderaiser/jonny.git"
},
"keywords": [
"json",
"try"
],
"author": "coderaiser <mnemonic.enemy@gmail.com> (http://coderaiser.github.io/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/coderaiser/jonny/issues"
},
"homepage": "https://github.com/coderaiser/jonny"
}

View file

@ -1,35 +0,0 @@
{
"name": "rendy",
"version": "1.1.0",
"homepage": "https://github.com/coderaiser/rendy",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"description": "simple template engine",
"main": "lib/rendy.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"template",
"engine",
"rendy"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"test"
],
"_release": "1.1.0",
"_resolution": {
"type": "version",
"tag": "v1.1.0",
"commit": "4ad810d131db34863df83977afea92b6fb2f1127"
},
"_source": "git://github.com/coderaiser/rendy.git",
"_target": "~1.1.0",
"_originalSource": "rendy",
"_direct": true
}

View file

@ -1,59 +0,0 @@
2015.05.21, v1.1.0
feature:
- (rendy) 5 times spead up
- (package) should v6.0.1
- (travis) add iojs, rm global gulp
- (package) scripts: test
- (test) greedy
- (package) should v5.2
- (package) scripts: gulp
2015.03.13, v1.0.6
fix:
- (rendy) clean up regexp: lazy -> greedy
2015.03.13, v1.0.5
feature:
- (rendy) put vars in forEach
- (package) should v5.0.0
- (bower) add
2015.01.26, v1.0.4
feature:
- (rendy) improve speed
2015.01.26, v1.0.3
feature:
- (rendy) speed up in 10 times: rm greedy quantifier
- (package) should v4.6
- (package) should v4.4.1
2014.12.12, v1.0.2
fix:
- (util) render: do not remove empty blocks "{{", "}}"
- (rendy) indexOf -> ~indexOf
feature:
- (package) v1.0.1
- (rendy) add expr
2014.12.12, v1.0.1
fix:
- (rendy) indexOf -> ~indexOf
feature:
- (rendy) add expr

View file

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014-2015 coderaiser
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,52 +0,0 @@
# Rendy [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL]
Simple template engine compatible with [handlebars](http://handlebarsjs.com "Handlebars") and [mustache](https://mustache.github.io "Mustache").
## Install
![NPM_INFO][NPM_INFO_IMG]
`npm i rendy --save`
## How to use?
Rendy could be used in browser or node.
Browser version:
```html
<script src="rendy.js"></script>
<script>
var Tmpl = 'hello {{ where }}';
result = rendy(Tmpl, {
where: 'in browser'
});
// returns
'hello in browser'
</script>
```
Node version:
```js
var rendy = require('rendy'),
Tmpl = 'hello {{ who }}';
result = rendy(Tmpl, {
who: 'world'
});
// returns
'hello world'
```
## License
MIT
[NPM_INFO_IMG]: https://nodei.co/npm/rendy.png?downloads&&stars&&downloadRank "npm install rendy"
[NPMIMGURL]: https://img.shields.io/npm/v/rendy.svg?style=flat
[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/rendy/master.svg?style=flat
[DependencyStatusIMGURL]: https://img.shields.io/gemnasium/coderaiser/rendy.svg?style=flat
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[NPMURL]: https://npmjs.org/package/rendy "npm"
[BuildStatusURL]: https://travis-ci.org/coderaiser/rendy "Build Status"
[DependencyStatusURL]: https://gemnasium.com/coderaiser/rendy "Dependency Status"
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"

View file

@ -1,25 +0,0 @@
{
"name": "rendy",
"version": "1.1.0",
"homepage": "https://github.com/coderaiser/rendy",
"authors": [
"coderaiser <mnemonic.enemy@gmail.com>"
],
"description": "simple template engine",
"main": "lib/rendy.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"template",
"engine",
"rendy"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"test"
]
}

View file

@ -1,18 +0,0 @@
(function() {
'use strict';
var gulp = require('gulp'),
mocha = require('gulp-mocha');
gulp.task('test', function() {
gulp.src('test/test.js')
.pipe(mocha({reporter: 'min'}))
.on('error', onError);
});
gulp.task('default', ['test']);
function onError(error) {
console.log(error.message);
}
})();

View file

@ -1,43 +0,0 @@
(function(global) {
'use strict';
if (typeof module === 'object' && module.exports)
module.exports = rendy;
else
global.rendy = rendy;
/**
* render template with data
*
* @param templ
* @param data
*/
function rendy(templ, data) {
var result = templ;
check(templ, data);
Object
.keys(data)
.forEach(function(param) {
var name = '{{ ' + param + ' }}',
str = data[param];
while(~result.indexOf(name))
result = result.replace(name, str);
});
if (~result.indexOf('{{'))
result = result.replace(/{{.*?}}/g, '');
return result;
}
function check(templ, data) {
if (typeof templ !== 'string')
throw(Error('template should be string!'));
if (typeof data !== 'object')
throw(Error('data should be object!'));
}
})(this);

View file

@ -1,28 +0,0 @@
{
"name": "rendy",
"version": "1.1.0",
"description": "simplest template engine",
"main": "lib/rendy.js",
"scripts": {
"test": "gulp test"
},
"repository": {
"type": "git",
"url": "git://github.com/coderaiser/rendy.git"
},
"keywords": [
"template",
"engine"
],
"author": "coderaiser <mnemonic.enemy@gmail.com> (http://coderaiser.github.io/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/coderaiser/rendy/issues"
},
"homepage": "https://github.com/coderaiser/rendy",
"devDependencies": {
"gulp": "~3.8.10",
"gulp-mocha": "~2.0.0",
"should": "~6.0.1"
}
}