Comparing version 0.0.20151202 to 0.1.0
{ | ||
"name": "zero-lang", | ||
"title": "zero-lang", | ||
"description": "", | ||
"homepage": "https://github.com/zero/zero-lang", | ||
"version": "0.0.20151202", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"author": { | ||
"description": "team of zero", | ||
"url": "https://github.com/orgs/zero/teams" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/zero/zero-lang/issues" | ||
}, | ||
"dependencies": { | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.2.1", | ||
"babel-preset-es2015": "^6.1.18" | ||
}, | ||
"engines": { | ||
"node": ">=0.8.0" | ||
}, | ||
"keywords": [ | ||
"zero", | ||
"zero-lang" | ||
], | ||
"repository": { | ||
"type": "https", | ||
"url": "https://github.com/zero/zero-lang.git" | ||
}, | ||
"scripts": { | ||
} | ||
"name": "zero-lang", | ||
"title": "language utils(like underscore)", | ||
"description": "", | ||
"homepage": "https://github.com/leungwensen/zero-lang", | ||
"version": "0.1.0", | ||
"main": "lib/index.js", | ||
"author": "leungwensen", | ||
"bugs": { | ||
"url": "https://github.com/leungwensen/zero-lang/issues" | ||
}, | ||
"dependencies": { | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.7.7", | ||
"babel-core": "^6.7.7", | ||
"babel-loader": "^6.2.4", | ||
"babel-preset-es2015": "^6.6.0", | ||
"chai": "3.5.0", | ||
"eslint": "^2.8.0", | ||
"eslint-config-airbnb": "^8.0.0", | ||
"eslint-plugin-import": "^1.6.0", | ||
"eslint-plugin-jsx-a11y": "^1.2.0", | ||
"eslint-plugin-markdown": "^1.0.0-beta.2", | ||
"eslint-plugin-react": "^5.1.1", | ||
"extract-text-webpack-plugin": "^1.0.1", | ||
"gulp": "^3.9.1", | ||
"gulp-eslint": "^2.0.0", | ||
"gulp-if": "^2.0.0", | ||
"gulp-jsdoc3": "^0.2.1", | ||
"gulp-plumber": "^1.1.0", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-util": "^3.0.7", | ||
"jsdoc": "^3.4.0", | ||
"mocha": "^2.4.5", | ||
"open": "^0.0.5", | ||
"pre-commit": "^1.1.2", | ||
"require-dir": "^0.3.0", | ||
"webpack": "^1.13.0", | ||
"webpack-dev-server": "^1.14.1" | ||
}, | ||
"engines": { | ||
"node": ">=4.0.0" | ||
}, | ||
"keywords": [ | ||
"zero", | ||
"lang", | ||
"zero-lang" | ||
], | ||
"license": "MIT", | ||
"repository": { | ||
"type": "ssh", | ||
"url": "git@github.com:leungwensen/zero-lang.git" | ||
}, | ||
"scripts": { | ||
"eslint": "gulp eslint" | ||
}, | ||
"pre-commit": [ | ||
"eslint" | ||
] | ||
} |
@@ -1,4 +0,17 @@ | ||
# zero-lang | ||
zero-lang | ||
==================== | ||
## install | ||
```shell | ||
npm install zero-lang --save | ||
``` | ||
## links | ||
* [API](./doc/api.md) | ||
* [demo](./demo) | ||
* [jsdoc](./doc/jsdoc) | ||
* [dev](./doc/dev.md) | ||
* [test](./spec) | ||
@@ -0,84 +1,78 @@ | ||
const zeroLang = require('../lib'); | ||
const expect = chai.expect; | ||
var array = require('../array.js'); | ||
describe('zero-array', () => { | ||
const indexOf = zeroLang.index(true); | ||
const lastIndexOf = zeroLang.index(false); | ||
let arrA; | ||
let arrB; | ||
describe('zero-array', function () { | ||
var arrA; | ||
var arrB; | ||
var indexOf = array.index(true); | ||
var lastIndexOf = array.index(false); | ||
beforeEach(() => { | ||
arrA = [1, 2, 3, 3, 4, 4, 4, 5]; | ||
arrB = []; | ||
}); | ||
beforeEach(function () { | ||
arrA = [1, 2, 3, 3, 4, 4, 4, 5]; | ||
arrB = []; | ||
}); | ||
it('zeroLang.indexOf(arr, searchElement, fromIndex)', () => { | ||
expect(indexOf(arrA, 1)).to.equal(0); | ||
expect(indexOf(arrA, 4)).to.equal(4); | ||
expect(indexOf(arrA, 5)).to.equal(7); | ||
expect(indexOf(arrA, 6)).to.equal(-1); | ||
}); | ||
it('array.indexOf(arr, searchElement, fromIndex)', function () { | ||
expect(indexOf(arrA, 1)).toBe(0); | ||
expect(indexOf(arrA, 4)).toBe(4); | ||
expect(indexOf(arrA, 5)).toBe(7); | ||
expect(indexOf(arrA, 6)).toBe(-1); | ||
it('zeroLang.lastIndexOf(arr, searchElement, fromIndex)', () => { | ||
expect(lastIndexOf(arrA, 5)).to.equal(7); | ||
expect(lastIndexOf(arrA, 3)).to.equal(3); | ||
expect(lastIndexOf(arrA, 2)).to.equal(1); | ||
expect(lastIndexOf(arrA, 6)).to.equal(-1); | ||
}); | ||
it('zeroLang.forEach(obj, callback, thisObj)', () => { | ||
zeroLang.forEach(arrA, (a) => { | ||
a += 0; | ||
arrB.push(a); | ||
}); | ||
it('array.lastIndexOf(arr, searchElement, fromIndex)', function () { | ||
expect(lastIndexOf(arrA, 5)).toBe(7); | ||
expect(lastIndexOf(arrA, 3)).toBe(3); | ||
expect(lastIndexOf(arrA, 2)).toBe(1); | ||
expect(lastIndexOf(arrA, 6)).toBe(-1); | ||
expect(arrB).to.deep.equal([1, 2, 3, 3, 4, 4, 4, 5]); | ||
arrB = []; | ||
zeroLang.forEach(arrA, (a) => { | ||
a += 1; | ||
arrB.push(a); | ||
}); | ||
it('array.forEach(obj, callback, thisObj)', function () { | ||
array.forEach(arrA, function (a) { | ||
a += 0; | ||
arrB.push(a); | ||
}); | ||
expect(arrB).toEqual([1, 2, 3, 3, 4, 4, 4, 5]); | ||
arrB = []; | ||
array.forEach(arrA, function (a) { | ||
a += 1; | ||
arrB.push(a); | ||
}); | ||
expect(arrB).toEqual([2, 3, 4, 4, 5, 5, 5, 6]); | ||
expect(arrB).to.deep.equal([2, 3, 4, 4, 5, 5, 5, 6]); | ||
}); | ||
it('zeroLang.every(obj, callback, thisObj)', () => { // alias | ||
expect(zeroLang.every(arrA, (item) => item === 4)).to.equal(false); | ||
}); | ||
it('zeroLang.some(obj, callback, thisObj)', () => { // alias | ||
expect(zeroLang.some(arrA, (item) => item === 4)).to.equal(true); | ||
}); | ||
it('zeroLang.each(obj, callback, thisObj)', () => { // alias | ||
zeroLang.each(arrA, (a) => { | ||
a += 0; | ||
arrB.push(a); | ||
}); | ||
it('array.every(obj, callback, thisObj)', function () { // alias | ||
expect(array.every(arrA, function(item) { | ||
return item === 4; | ||
})).toEqual(false); | ||
expect(arrB).to.deep.equal([1, 2, 3, 3, 4, 4, 4, 5]); | ||
arrB = []; | ||
zeroLang.each(arrA, (a) => { | ||
a += 1; | ||
arrB.push(a); | ||
}); | ||
it('array.some(obj, callback, thisObj)', function () { // alias | ||
expect(array.some(arrA, function(item) { | ||
return item === 4; | ||
})).toEqual(true); | ||
expect(arrB).to.deep.equal([2, 3, 4, 4, 5, 5, 5, 6]); | ||
}); | ||
it('zeroLang.remove(arr, fromIndex, toIndex)', () => { | ||
zeroLang.remove(arrA, 0, 2); | ||
expect(arrA).to.deep.equal([3, 4, 4, 4, 5]); | ||
zeroLang.remove(arrA, 0); | ||
expect(arrA).to.deep.equal([4, 4, 4, 5]); | ||
zeroLang.remove(arrA, 0, -1); | ||
expect(arrA).to.deep.equal([]); | ||
}); | ||
it('CANNOT use zeroLang.remove() inside of zeroLang.each() callback to THE SAME ARRAY', () => { | ||
zeroLang.each(arrA, (num, i) => { | ||
if (num === 4) { | ||
zeroLang.remove(arrA, i); | ||
} | ||
}); | ||
it('array.each(obj, callback, thisObj)', function () { // alias | ||
array.each(arrA, function (a) { | ||
a += 0; | ||
arrB.push(a); | ||
}); | ||
expect(arrB).toEqual([1, 2, 3, 3, 4, 4, 4, 5]); | ||
arrB = []; | ||
array.each(arrA, function (a) { | ||
a += 1; | ||
arrB.push(a); | ||
}); | ||
expect(arrB).toEqual([2, 3, 4, 4, 5, 5, 5, 6]); | ||
}); | ||
it('array.remove(arr, fromIndex, toIndex)', function () { | ||
array.remove(arrA, 0, 2); | ||
expect(arrA).toEqual([3, 4, 4, 4, 5]); | ||
array.remove(arrA, 0); | ||
expect(arrA).toEqual([4, 4, 4, 5]); | ||
array.remove(arrA, 0, -1); | ||
expect(arrA).toEqual([]); | ||
}); | ||
it('CANNOT use array.remove() inside of array.each() callback to THE SAME ARRAY', function () { | ||
array.each(arrA, function (num, i) { | ||
if (num === 4) { | ||
array.remove(arrA, i); | ||
} | ||
}); | ||
expect(arrA).not.toEqual([1, 2, 3, 3, 5]); | ||
expect(arrA).not.toEqual([1, 2, 3, 3, 4, 4, 4, 5]); | ||
expect(arrA).toEqual([1, 2, 3, 3, 4, 5]); // !!!!!!!!!! REMEMBER THIS !!!!!!!!!! | ||
}); | ||
expect(arrA).not.to.deep.equal([1, 2, 3, 3, 5]); | ||
expect(arrA).not.to.deep.equal([1, 2, 3, 3, 4, 4, 4, 5]); | ||
expect(arrA).to.deep.equal([1, 2, 3, 3, 4, 5]); // !!!!!!!!!! REMEMBER THIS !!!!!!!!!! | ||
}); | ||
}); | ||
@@ -0,13 +1,13 @@ | ||
/* globals hello */ | ||
const zeroLang = require('../lib'); | ||
const expect = chai.expect; | ||
var zeroLangGlobal = require('../global.js'); | ||
describe('zero-lang-global', function () { | ||
it('exists', function () { | ||
expect(typeof zeroLangGlobal).toEqual('object'); | ||
}); | ||
it('works', function () { | ||
zeroLangGlobal.hello = 'world'; | ||
expect(hello).toBe('world'); | ||
}); | ||
describe('zero-lang-global', () => { | ||
it('exists', () => { | ||
expect(typeof zeroLang.global).to.equal('object'); | ||
}); | ||
it('works', () => { | ||
zeroLang.global.hello = 'world'; | ||
expect(hello).to.equal('world'); | ||
}); | ||
}); | ||
@@ -0,72 +1,69 @@ | ||
const zeroLang = require('../lib'); | ||
const expect = chai.expect; | ||
var arrayUtils = require('../array.js'); | ||
var number = require('../number.js'); | ||
describe('zero-number', function () { | ||
it('zero-number.isDecimal', function () { | ||
expect(number.isDecimal(1)).toBe(false); | ||
expect(number.isDecimal(1.1)).toBe(true); | ||
expect(number.isDecimal('1')).toBe(false); | ||
describe('zero-number', () => { | ||
it('zero-number.isDecimal', () => { | ||
expect(zeroLang.isDecimal(1)).to.equal(false); | ||
expect(zeroLang.isDecimal(1.1)).to.equal(true); | ||
expect(zeroLang.isDecimal('1')).to.equal(false); | ||
}); | ||
it('zero-number.isEven', () => { // 偶数 | ||
expect(zeroLang.isEven(1)).to.equal(false); | ||
expect(zeroLang.isEven(20)).to.equal(true); | ||
expect(zeroLang.isEven(0)).to.equal(true); | ||
expect(zeroLang.isEven('1')).to.equal(false); | ||
}); | ||
it('zero-number.isOdd', () => { // 奇数 | ||
expect(zeroLang.isOdd(1)).to.equal(true); | ||
expect(zeroLang.isOdd(20)).to.equal(false); | ||
expect(zeroLang.isOdd(0)).to.equal(false); | ||
expect(zeroLang.isOdd('1')).to.equal(false); | ||
}); | ||
it('zero-number.isInteger', () => { | ||
expect(zeroLang.isInteger(1)).to.equal(true); | ||
expect(zeroLang.isInteger(20.1)).to.equal(false); | ||
expect(zeroLang.isInteger(0.0)).to.equal(true); | ||
expect(zeroLang.isInteger('1')).to.equal(false); | ||
}); | ||
it('zero-number.isNegative', () => { | ||
expect(zeroLang.isNegative(1)).to.equal(false); | ||
expect(zeroLang.isNegative(-20.1)).to.equal(true); | ||
expect(zeroLang.isNegative(0.0)).to.equal(false); | ||
expect(zeroLang.isNegative('1')).to.equal(false); | ||
}); | ||
it('zero-number.isPositive', () => { | ||
expect(zeroLang.isPositive(1)).to.equal(true); | ||
expect(zeroLang.isPositive(-20.1)).to.equal(false); | ||
expect(zeroLang.isPositive(0.0)).to.equal(false); | ||
expect(zeroLang.isPositive('1')).to.equal(false); | ||
}); | ||
it('zero-number.isNumber', () => { | ||
expect(zeroLang.isNumber(NaN)).to.equal(true); | ||
expect(zeroLang.isNumber(1)).to.equal(true); | ||
expect(zeroLang.isNumber('1')).to.equal(false); | ||
}); | ||
it('zero-number.isInRange', () => { | ||
const falsey = [undefined, '', 0, false, NaN, null, undefined]; | ||
expect(zeroLang.isInRange(3, 5)).to.equal(true); | ||
expect(zeroLang.isInRange(5, 5)).to.equal(false); | ||
expect(zeroLang.isInRange(6, 5)).to.equal(false); | ||
expect(zeroLang.isInRange(5.2, 5)).to.equal(false); | ||
expect(zeroLang.isInRange(0.5, 5)).to.equal(true); | ||
expect(zeroLang.isInRange(1, 1, 5)).to.equal(true); | ||
expect(zeroLang.isInRange(3, 1, 5)).to.equal(true); | ||
expect(zeroLang.isInRange(0, 1, 5)).to.equal(false); | ||
expect(zeroLang.isInRange(5, 1, 5)).to.equal(false); | ||
expect(zeroLang.isInRange(1.2, 1, 5)).to.equal(true); | ||
expect(zeroLang.isInRange(0.5, 1, 5)).to.equal(false); | ||
expect(zeroLang.isInRange(2, 5, 1)).to.equal(true); | ||
expect(zeroLang.isInRange(-3, -2, -6)).to.equal(true); | ||
zeroLang.each(falsey, (value, index) => { | ||
if (index) { | ||
expect(zeroLang.isInRange(0, value)).to.equal(false); | ||
expect(zeroLang.isInRange(0, value, 1)).to.equal(true); | ||
} else { | ||
expect(zeroLang.isInRange(0)).to.equal(false); | ||
} | ||
}); | ||
it('zero-number.isEven', function () { // 偶数 | ||
expect(number.isEven(1)).toBe(false); | ||
expect(number.isEven(20)).toBe(true); | ||
expect(number.isEven(0)).toBe(true); | ||
expect(number.isEven('1')).toBe(false); | ||
}); | ||
it('zero-number.isOdd', function () { // 奇数 | ||
expect(number.isOdd(1)).toBe(true); | ||
expect(number.isOdd(20)).toBe(false); | ||
expect(number.isOdd(0)).toBe(false); | ||
expect(number.isOdd('1')).toBe(false); | ||
}); | ||
it('zero-number.isInteger', function () { | ||
expect(number.isInteger(1)).toBe(true); | ||
expect(number.isInteger(20.1)).toBe(false); | ||
expect(number.isInteger(0.0)).toBe(true); | ||
expect(number.isInteger('1')).toBe(false); | ||
}); | ||
it('zero-number.isNegative', function () { | ||
expect(number.isNegative(1)).toBe(false); | ||
expect(number.isNegative(-20.1)).toBe(true); | ||
expect(number.isNegative(0.0)).toBe(false); | ||
expect(number.isNegative('1')).toBe(false); | ||
}); | ||
it('zero-number.isPositive', function () { | ||
expect(number.isPositive(1)).toBe(true); | ||
expect(number.isPositive(-20.1)).toBe(false); | ||
expect(number.isPositive(0.0)).toBe(false); | ||
expect(number.isPositive('1')).toBe(false); | ||
}); | ||
it('zero-number.isNumber', function () { | ||
expect(number.isNumber(NaN)).toBe(true); | ||
expect(number.isNumber(1)).toBe(true); | ||
expect(number.isNumber('1')).toBe(false); | ||
}); | ||
it('zero-number.isInRange', function () { | ||
var falsey = [, '', 0, false, NaN, null, undefined]; | ||
expect(number.isInRange(3 , 5)).toBe(true); | ||
expect(number.isInRange(5 , 5)).toBe(false); | ||
expect(number.isInRange(6 , 5)).toBe(false); | ||
expect(number.isInRange(5.2 , 5)).toBe(false); | ||
expect(number.isInRange(0.5 , 5)).toBe(true); | ||
expect(number.isInRange(1 , 1 , 5 )).toBe(true); | ||
expect(number.isInRange(3 , 1 , 5 )).toBe(true); | ||
expect(number.isInRange(0 , 1 , 5 )).toBe(false); | ||
expect(number.isInRange(5 , 1 , 5 )).toBe(false); | ||
expect(number.isInRange(1.2 , 1 , 5 )).toBe(true); | ||
expect(number.isInRange(0.5 , 1 , 5 )).toBe(false); | ||
expect(number.isInRange(2 , 5 , 1 )).toBe(true); | ||
expect(number.isInRange(-3 , -2 , -6)).toBe(true); | ||
arrayUtils.each(falsey, function(value, index) { | ||
if (index) { | ||
expect(number.isInRange(0, value )).toBe(false); | ||
expect(number.isInRange(0, value, 1)).toBe(true); | ||
} else { | ||
expect(number.isInRange(0)).toBe(false); | ||
} | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -0,83 +1,82 @@ | ||
const zeroLang = require('../lib'); | ||
const expect = chai.expect; | ||
var object = require('../object.js'); | ||
describe('zero-object', function () { | ||
var obj = { | ||
foo: 'bar', | ||
hoo: 'goo' | ||
}; | ||
it('delete in zero-object.forIn()', function () { | ||
object.forIn(obj, function (value, key) { | ||
if (value === 'bar') { | ||
delete obj[key]; | ||
} | ||
}); | ||
expect(obj).toEqual({ // !!!!!!!!!! REMEMBER THIS !!!!!!!!!! | ||
hoo: 'goo' | ||
}); | ||
describe('zero-object', () => { | ||
const obj = { | ||
foo: 'bar', | ||
hoo: 'goo' | ||
}; | ||
it('delete in zero-object.forIn()', () => { | ||
zeroLang.forIn(obj, (value, key) => { | ||
if (value === 'bar') { | ||
delete obj[key]; | ||
} | ||
}); | ||
var destObj1 = {}, | ||
destObj2 = {}, | ||
obj1 = { | ||
hello: 'world' | ||
}, | ||
obj2 = { | ||
foo: 'bar', | ||
bar: { | ||
hi: 'hello', | ||
woo: 'weee', | ||
wee: { | ||
hoo: 'gee', | ||
hi: 'hi' | ||
} | ||
} | ||
}, | ||
obj3 = { | ||
foo: 'too', | ||
bar: { | ||
woo: 'waaa', | ||
wee: { | ||
hi: 'hoo' | ||
} | ||
}, | ||
hello: [ | ||
'world', | ||
'html', | ||
'object' | ||
] | ||
}; | ||
object.merge(destObj1, obj1, obj2, obj3); | ||
it('object.merge(dest)', function () { // 深度合并 | ||
// expect(destObj1.hello).toBe('world'); | ||
expect(destObj1.foo).toBe('too'); | ||
expect(destObj1.bar.woo).toBe('waaa'); | ||
expect(destObj1.bar.hi).toBe('hello'); | ||
expect(destObj1.bar.wee.hoo).toBe('gee'); | ||
expect(destObj1.bar.wee.hi).toBe('hoo'); | ||
expect(destObj1.hello).toEqual(['world', 'html', 'object']); | ||
expect(Object.prototype.toString.call(destObj1.hello)).toBe('[object Array]'); | ||
expect(obj).to.deep.equal({ // !!!!!!!!!! REMEMBER THIS !!!!!!!!!! | ||
hoo: 'goo' | ||
}); | ||
object.extend(destObj2, obj1, obj2, obj3); | ||
it('object.extend(dest)', function () { // 扩展 | ||
expect(destObj1.hello).toEqual(['world', 'html', 'object']); | ||
expect(destObj2.foo).toBe('too'); | ||
expect(destObj2.bar.woo).toBe('waaa'); | ||
expect(destObj2.bar.hi).toBe(undefined); | ||
expect(destObj2.bar.wee.hoo).toBe(undefined); | ||
expect(destObj2.bar.wee.hi).toBe('hoo'); | ||
}); | ||
}); | ||
it('object.clone(dest)', function() { | ||
expect(object.clone(obj2).bar).not.toBe(obj2.bar); | ||
expect(object.clone(obj2).bar).toEqual(obj2.bar); | ||
}); | ||
const destObj1 = {}; | ||
const destObj2 = {}; | ||
const obj1 = { | ||
hello: 'world' | ||
}; | ||
const obj2 = { | ||
foo: 'bar', | ||
bar: { | ||
hi: 'hello', | ||
woo: 'weee', | ||
wee: { | ||
hoo: 'gee', | ||
hi: 'hi' | ||
} | ||
} | ||
}; | ||
const obj3 = { | ||
foo: 'too', | ||
bar: { | ||
woo: 'waaa', | ||
wee: { | ||
hi: 'hoo' | ||
} | ||
}, | ||
hello: [ | ||
'world', | ||
'html', | ||
'object' | ||
] | ||
}; | ||
zeroLang.merge(destObj1, obj1, obj2, obj3); | ||
it('object.merge(dest)', () => { // 深度合并 | ||
// expect(destObj1.hello).to.equal('world'); | ||
expect(destObj1.foo).to.equal('too'); | ||
expect(destObj1.bar.woo).to.equal('waaa'); | ||
expect(destObj1.bar.hi).to.equal('hello'); | ||
expect(destObj1.bar.wee.hoo).to.equal('gee'); | ||
expect(destObj1.bar.wee.hi).to.equal('hoo'); | ||
expect(destObj1.hello).to.deep.equal(['world', 'html', 'object']); | ||
expect(Object.prototype.toString.call(destObj1.hello)).to.equal('[object Array]'); | ||
}); | ||
zeroLang.extend(destObj2, obj1, obj2, obj3); | ||
it('object.extend(dest)', () => { // 扩展 | ||
expect(destObj1.hello).to.deep.equal(['world', 'html', 'object']); | ||
expect(destObj2.foo).to.equal('too'); | ||
expect(destObj2.bar.woo).to.equal('waaa'); | ||
expect(destObj2.bar.hi).to.equal(undefined); | ||
expect(destObj2.bar.wee.hoo).to.equal(undefined); | ||
expect(destObj2.bar.wee.hi).to.equal('hoo'); | ||
}); | ||
it('object.invert(obj)', function() { | ||
expect(object.invert(obj2.bar.wee)).toEqual({ | ||
gee: 'hoo', | ||
hi: 'hi' | ||
}); | ||
it('object.clone(dest)', () => { | ||
expect(zeroLang.clone(obj2).bar).not.to.equal(obj2.bar); | ||
expect(zeroLang.clone(obj2).bar).to.deep.equal(obj2.bar); | ||
}); | ||
it('object.invert(obj)', () => { | ||
expect(zeroLang.invert(obj2.bar.wee)).to.deep.equal({ | ||
gee: 'hoo', | ||
hi: 'hi' | ||
}); | ||
}); | ||
}); | ||
@@ -0,31 +1,30 @@ | ||
const zeroLang = require('../lib'); | ||
const expect = chai.expect; | ||
var string = require('../string.js'); | ||
describe('zero-string', function () { | ||
it('zero-string.isString', function () { | ||
expect(string.isString('')).toBe(true); | ||
}); | ||
it('zero-string.trim', function () { | ||
expect(string.trim(' ')).toBe(''); | ||
expect(string.trim(' a')).toBe('a'); | ||
expect(string.trim('b ')).toBe('b'); | ||
expect(string.trim('b a')).toBe('b a'); | ||
}); | ||
it('zero-string.trimLeft', function () { | ||
expect(string.trimLeft(' a')).toBe('a'); | ||
expect(string.trimLeft('b ')).toBe('b '); | ||
expect(string.trimLeft('b a')).toBe('b a'); | ||
}); | ||
it('zero-string.trimRight', function () { | ||
expect(string.trimRight(' a')).toBe(' a'); | ||
expect(string.trimRight('b ')).toBe('b'); | ||
expect(string.trimRight('b a')).toBe('b a'); | ||
}); | ||
it('zero-string.hasSubString', function () { | ||
expect(string.hasSubString(' a', 'a')).toBe(true); | ||
expect(string.hasSubString('b ', 'a')).toBe(false); | ||
expect(string.hasSubString('b a', 'b ')).toBe(true); | ||
}); | ||
describe('zero-string', () => { | ||
it('zero-string.isString', () => { | ||
expect(zeroLang.isString('')).to.equal(true); | ||
}); | ||
it('zero-string.trim', () => { | ||
expect(zeroLang.trim(' ')).to.equal(''); | ||
expect(zeroLang.trim(' a')).to.equal('a'); | ||
expect(zeroLang.trim('b ')).to.equal('b'); | ||
expect(zeroLang.trim('b a')).to.equal('b a'); | ||
}); | ||
it('zero-string.trimLeft', () => { | ||
expect(zeroLang.trimLeft(' a')).to.equal('a'); | ||
expect(zeroLang.trimLeft('b ')).to.equal('b '); | ||
expect(zeroLang.trimLeft('b a')).to.equal('b a'); | ||
}); | ||
it('zero-string.trimRight', () => { | ||
expect(zeroLang.trimRight(' a')).to.equal(' a'); | ||
expect(zeroLang.trimRight('b ')).to.equal('b'); | ||
expect(zeroLang.trimRight('b a')).to.equal('b a'); | ||
}); | ||
it('zero-string.hasSubString', () => { | ||
expect(zeroLang.hasSubString(' a', 'a')).to.equal(true); | ||
expect(zeroLang.hasSubString('b ', 'a')).to.equal(false); | ||
expect(zeroLang.hasSubString('b a', 'b ')).to.equal(true); | ||
}); | ||
}); | ||
@@ -0,55 +1,54 @@ | ||
const zeroLang = require('../lib'); | ||
const expect = chai.expect; | ||
var type = require('../type.js'); | ||
function noop() { | ||
} | ||
function noop() {} | ||
describe('zero-type.is$Type(obj)', function () { | ||
it('zero-type.isArguments', function () { | ||
expect(type.isArguments([])).toBe(false); | ||
expect(type.isArguments(arguments)).toBe(true); | ||
}); | ||
it('zero-type.isArray', function () { | ||
expect(type.isArray([])).toBe(true); | ||
expect(type.isArray(1)).toBe(false); | ||
}); | ||
it('zero-type.isBoolean', function () { | ||
expect(type.isBoolean(true)).toBe(true); | ||
expect(type.isBoolean(false)).toBe(true); | ||
expect(type.isBoolean(1)).toBe(false); | ||
}); | ||
it('zero-type.isFunction', function () { | ||
expect(type.isFunction(noop)).toBe(true); | ||
expect(type.isFunction(1)).toBe(false); | ||
}); | ||
it('zero-type.isNumber', function () { | ||
expect(type.isNumber(NaN)).toBe(true); | ||
expect(type.isNumber(1)).toBe(true); | ||
expect(type.isNumber('1')).toBe(false); | ||
}); | ||
it('zero-type.isObject', function () { | ||
expect(type.isObject({})).toBe(true); | ||
expect(type.isObject(null)).toBe(false); | ||
expect(type.isObject(noop.prototype)).toBe(true); | ||
expect(type.isObject(noop)).toBe(true); | ||
}); | ||
it('zero-type.isPlainObject', function () { | ||
expect(type.isPlainObject({})).toBe(true); | ||
expect(type.isPlainObject(null)).toBe(false); | ||
expect(type.isPlainObject(noop.prototype)).toBe(true); | ||
expect(type.isPlainObject(noop)).toBe(false); | ||
}); | ||
it('zero-type.isString', function () { | ||
expect(type.isString('')).toBe(true); | ||
}); | ||
it('zero-type.isError', function () { | ||
expect(type.isError(new Error())).toBe(true); | ||
}); | ||
it('zero-type.isDate', function () { | ||
expect(type.isDate(new Date())).toBe(true); | ||
}); | ||
it('zero-type.isRegExp', function () { | ||
expect(type.isRegExp(/^..$/)).toBe(true); | ||
}); | ||
describe('zero-lang.is$Type(obj)', () => { | ||
it('zero-lang.isArguments', () => { | ||
expect(zeroLang.isArguments([])).to.equal(false); | ||
expect(zeroLang.isArguments(arguments)).to.equal(true); | ||
}); | ||
it('zero-lang.isArray', () => { | ||
expect(zeroLang.isArray([])).to.equal(true); | ||
expect(zeroLang.isArray(1)).to.equal(false); | ||
}); | ||
it('zero-lang.isBoolean', () => { | ||
expect(zeroLang.isBoolean(true)).to.equal(true); | ||
expect(zeroLang.isBoolean(false)).to.equal(true); | ||
expect(zeroLang.isBoolean(1)).to.equal(false); | ||
}); | ||
it('zero-lang.isFunction', () => { | ||
expect(zeroLang.isFunction(noop)).to.equal(true); | ||
expect(zeroLang.isFunction(1)).to.equal(false); | ||
}); | ||
it('zero-lang.isNumber', () => { | ||
expect(zeroLang.isNumber(NaN)).to.equal(true); | ||
expect(zeroLang.isNumber(1)).to.equal(true); | ||
expect(zeroLang.isNumber('1')).to.equal(false); | ||
}); | ||
it('zero-lang.isObject', () => { | ||
expect(zeroLang.isObject({})).to.equal(true); | ||
expect(zeroLang.isObject(null)).to.equal(false); | ||
expect(zeroLang.isObject(noop.prototype)).to.equal(true); | ||
expect(zeroLang.isObject(noop)).to.equal(true); | ||
}); | ||
it('zero-lang.isPlainObject', () => { | ||
expect(zeroLang.isPlainObject({})).to.equal(true); | ||
expect(zeroLang.isPlainObject(null)).to.equal(false); | ||
expect(zeroLang.isPlainObject(noop.prototype)).to.equal(true); | ||
expect(zeroLang.isPlainObject(noop)).to.equal(false); | ||
}); | ||
it('zero-lang.isString', () => { | ||
expect(zeroLang.isString('')).to.equal(true); | ||
}); | ||
it('zero-lang.isError', () => { | ||
expect(zeroLang.isError(new Error())).to.equal(true); | ||
}); | ||
it('zero-lang.isDate', () => { | ||
expect(zeroLang.isDate(new Date())).to.equal(true); | ||
}); | ||
it('zero-lang.isRegExp', () => { | ||
expect(zeroLang.isRegExp(/^..$/)).to.equal(true); | ||
}); | ||
}); | ||
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
34
2
18
32704
26
985
1