Package Exports
- some-values
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (some-values) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
some-values
I don't believe in magic
I don't believe in magic numbers
I don't believe in magic strings
When writing tests we often specify values
api.save(5)
expect(api.validate).calledWith(5)
This reads like 5 is important, but what if 5 isn't important, we are simply saying 'given I save a number I get a number'. Enter some-values
...
api.save(a.number)
expect(api.validate).calledWith(a.number)
Install
npm install --save-dev some-values
Use it
Basic
someValues = require('some-values')
a = someValues()
a.string // Returns a random string
a.string // Returns the same string
a.number // Returns a random number
a.number // Returns the same number
Multiple
Need multiple values?
a = someValues()
b = someValues()
a.string // Returns a random string
b.string // Returns another random string
a.string // Returns the first string
Supported Values
String
A random Length of Char
0 < Length < 20
Char = [a..b]
Number
A random number of Value
0 < Value < 100
Digit
A random number of Value
0 <= Value <= 9
Bring your own
a = someValues({
string: () => 'myOwnString'
reallyLongNumber: () => 1000 + Math.floor(Math.random()*1000)
})
What's on the horizon?
Add Date, ISO Datetime