Comparing version 0.0.0-beta.0 to 0.0.0-beta.1
@@ -1,6 +0,7 @@ | ||
export { default as generators } from './generators'; | ||
export { default as getters } from './getters'; | ||
export { default as generators } from './src/generators'; | ||
export { default as getters } from './src/getters'; | ||
export { | ||
isUn, | ||
isNull, | ||
isValid, | ||
isObj, | ||
@@ -16,6 +17,6 @@ isBool, | ||
isArrEmpty, | ||
} from './is'; | ||
} from './src/is'; | ||
export { | ||
hasKey, | ||
} from './has'; | ||
} from './src/has'; |
{ | ||
"name": "aleppo", | ||
"version": "0.0.0-beta.0", | ||
"version": "0.0.0-beta.1", | ||
"description": "General node functions, useful for any project.", | ||
@@ -10,3 +10,4 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "mocha --compilers js:babel-core/register test" | ||
"test": "mocha --compilers js:babel-core/register test", | ||
"test-getters": "mocha --compilers js:babel-core/register test/getters.test.js" | ||
}, | ||
@@ -13,0 +14,0 @@ "repository": { |
@@ -1,38 +0,69 @@ | ||
# General collection for useful node functions. | ||
# Overview | ||
## is: true or false functions | ||
Aleppo is lightweight package written in javascript. It's toolbox contains general collection functions for node. | ||
**isUn(input)**: tests for undefined<br> | ||
**isNull(input)**: tests for null<br> | ||
**isObj(input)**: tests for object<br> | ||
**isBool(input)**: tests for Boolean<br> | ||
**isNum(input)**: tests for number<br> | ||
**isStr(input)**: tests for string<br> | ||
**isFn(input)**: tests for function<br> | ||
**isSymb(input)**: tests for symbol<br> | ||
**isArr(input)**: tests for array<br> | ||
**isZeroLength(input)**: tests for zero length<br> | ||
**isStrEmpty(input)**: tests if empty string<br> | ||
**isArrEmpty(input)**: tests if array is empty<br> | ||
# Getting Started | ||
## Generators: | ||
clone the repo: | ||
**Numbers**: | ||
```sh | ||
git clone git@github.com:jimmy02020/aleppo.git | ||
cd aleppo | ||
``` | ||
**const numbers = generators.numbers**: | ||
npm | ||
**numbers.getRandom(min, max, type)**: returns random number in given range. | ||
```sh | ||
$ npm install aleppo | ||
``` | ||
# Usage | ||
# IS: true or false functions | ||
```javascript | ||
isUn(input) //tests for undefined. | ||
isNull(input) //tests for null. | ||
isValid(input) //tests for not being undefined or null. | ||
isObj(input) //tests for object. | ||
isBool(input) //tests for Boolean. | ||
isNum(input) //tests for number. | ||
isStr(input) //tests for string. | ||
isFn(input) //tests for function. | ||
isSymb(input) //tests for symbol. | ||
isArr(input) //tests for array. | ||
isZeroLength(input) //tests for zero length. | ||
isStrEmpty(input) //tests if string is empty. | ||
isArrEmpty(input) //tests if array is empty.. | ||
``` | ||
min, max: range number, | ||
type: is string. By default will apply for integer random number. for arbitrary value just pass 'any'. | ||
``` | ||
## Getters: | ||
# Generators: | ||
**getters.object(param)**: discovers key and prop. | ||
1. **Numbers**: | ||
```javascript | ||
const numbers = generators.numbers; | ||
numbers.getRandom(min, max, type) //returns random number in given range. | ||
// type: is string. By default will apply for integer random number. for arbitrary value just pass 'any'. | ||
``` | ||
# Getters: | ||
1. **object**: | ||
```javascript | ||
getters.obj(input) // returns key and prop. | ||
// param = { foo: 'bar' }; | ||
// will return key = foo and prop = bar throws error if empty. | ||
``` | ||
# Tests | ||
```sh | ||
$ npm test | ||
``` | ||
param = { foo: 'bar' }; | ||
will return key = foo and prop = bar throws error if empty. | ||
``` | ||
# License | ||
This project is licensed under the [MIT License](https://github.com/Jimmy02020/aleppo/blob/master/LICENSE) |
/* eslint-env mocha */ | ||
import chai from 'chai'; | ||
import generators from '../generators'; | ||
import generators from '../src/generators'; | ||
@@ -10,8 +10,3 @@ const numbers = generators.numbers; | ||
describe('Generate random number', () => { | ||
it('1- throws an error because of parameters input dont match', () => { | ||
expect(() => { | ||
numbers.getRandom(10, '20', 'int'); | ||
}).to.throw(Error); | ||
}); | ||
it('2- generates number int', () => { | ||
it('1- generates number int', () => { | ||
expect(numbers.getRandom(10, 20) % 1).to.be.equal(0); | ||
@@ -22,5 +17,5 @@ }); | ||
}); | ||
it('4- generates number between specific range', () => { | ||
it('3- generates number between specific range', () => { | ||
expect(numbers.getRandom(11, 20)).to.be.within(11, 20); | ||
}); | ||
}); |
/* eslint-env mocha */ | ||
import chai from 'chai'; | ||
import getters from '../getters'; | ||
import getters from '../src/getters'; | ||
@@ -12,9 +12,9 @@ const expect = chai.expect; | ||
describe('getter', () => { | ||
it('1-gets object key', () => expect(getters.object(testParam).key).to.equal('foo')); | ||
it('2-gets object property', () => expect(getters.object(testParam).prop).to.equal('bar')); | ||
it('1-gets object key', () => expect(getters.obj(testParam).key).to.equal('foo')); | ||
it('2-gets object property', () => expect(getters.obj(testParam).prop).to.equal('bar')); | ||
it('3- throws an error because an empty object', () => { | ||
expect(() => { | ||
getters.object(testParam2); | ||
getters.obj(testParam2); | ||
}).to.throw(Error); | ||
}); | ||
}); |
@@ -7,2 +7,3 @@ /* eslint-env mocha */ | ||
isUn, | ||
isValid, | ||
isObj, | ||
@@ -18,3 +19,3 @@ isBool, | ||
isArrEmpty, | ||
} from '../is'; | ||
} from '../src/is'; | ||
@@ -27,11 +28,12 @@ const expect = chai.expect; | ||
it('2-tests null as null', () => expect(isNull(null)).to.be.true); | ||
it('3-tests {boo : foo} as object', () => expect(isObj({ boo: 'foo' })).to.be.true); | ||
it('4-tests true as boolean', () => expect(isBool(true)).to.be.true); | ||
it('5-tests 3 as number', () => expect(isNum(3)).to.be.true); | ||
it('6-tests hello as string', () => expect(isStr('hello')).to.be.true); | ||
it('7-tests ()=> 4 as function', () => expect(isFn(() => 4)).to.be.true); | ||
it('8-tests [10, 6, 8] as array', () => expect(isArr([10, 6, 8])).to.be.true); | ||
it('9-tests "" as zero length', () => expect(isZeroLength('')).to.be.true); | ||
it('10-tests " " as empty string', () => expect(isStrEmpty(' ')).to.be.true); | ||
it('11-tests [] empty array', () => expect(isArrEmpty([])).to.be.true); | ||
it('3-tests "welcome" as valid', () => expect(isValid('welcome')).to.be.true); | ||
it('4-tests {boo : foo} as object', () => expect(isObj({ boo: 'foo' })).to.be.true); | ||
it('5-tests true as boolean', () => expect(isBool(true)).to.be.true); | ||
it('6-tests 3 as number', () => expect(isNum(3)).to.be.true); | ||
it('7-tests hello as string', () => expect(isStr('hello')).to.be.true); | ||
it('8-tests ()=> 4 as function', () => expect(isFn(() => 4)).to.be.true); | ||
it('9-tests [10, 6, 8] as array', () => expect(isArr([10, 6, 8])).to.be.true); | ||
it('10-tests "" as zero length', () => expect(isZeroLength('')).to.be.true); | ||
it('11-tests " " as empty string', () => expect(isStrEmpty(' ')).to.be.true); | ||
it('12-tests [] empty array', () => expect(isArrEmpty([])).to.be.true); | ||
}); | ||
@@ -41,12 +43,14 @@ describe('should return false', () => { | ||
it('2-tests hello as null', () => expect(isNull('hello')).to.be.false); | ||
it('3-tests ()=> 4 as object', () => expect(isObj(() => 4)).to.be.false); | ||
it('4-tests null as boolean', () => expect(isBool(null)).to.be.false); | ||
it('5-tests hello 3 as number', () => expect(isNum('hello')).to.be.false); | ||
it('6-tests 3 as string', () => expect(isStr(3)).to.be.false); | ||
it('7-tests {boo : foo} as function', () => expect(isFn({ boo: 'foo' })).to.be.false); | ||
it('8-tests {foo: 123} as array', () => expect(isArr({ foo: 123 })).to.be.false); | ||
it('9-tests "what?" as zero length', () => expect(isZeroLength('what?')).to.be.false); | ||
it('10-tests "hell0" as empty string', () => expect(isStrEmpty('hell')).to.be.false); | ||
it('11-tests [5] empty array', () => expect(isArrEmpty([5])).to.be.false); | ||
it('3-tests null as valid', () => expect(isValid(null)).to.be.false); | ||
it('4-tests undefined as valid', () => expect(isValid(undefined)).to.be.false); | ||
it('5-tests ()=> 4 as object', () => expect(isObj(() => 4)).to.be.false); | ||
it('6-tests null as boolean', () => expect(isBool(null)).to.be.false); | ||
it('7-tests hello 3 as number', () => expect(isNum('hello')).to.be.false); | ||
it('8-tests 3 as string', () => expect(isStr(3)).to.be.false); | ||
it('9-tests {boo : foo} as function', () => expect(isFn({ boo: 'foo' })).to.be.false); | ||
it('10-tests {foo: 123} as array', () => expect(isArr({ foo: 123 })).to.be.false); | ||
it('11-tests "what?" as zero length', () => expect(isZeroLength('what?')).to.be.false); | ||
it('12-tests "hell0" as empty string', () => expect(isStrEmpty('hell')).to.be.false); | ||
it('13-tests [5] empty array', () => expect(isArrEmpty([5])).to.be.false); | ||
}); | ||
}); |
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
10486
19
70
193
1