@travi/any
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -17,2 +17,5 @@ 'use strict'; | ||
}; | ||
var float = function float(options) { | ||
return chance.floating(options); | ||
}; | ||
var string = function string(options) { | ||
@@ -97,2 +100,3 @@ return chance.string(options); | ||
integer: integer, | ||
float: float, | ||
boolean: boolean, | ||
@@ -109,2 +113,3 @@ url: url, | ||
exports.integer = integer; | ||
exports.float = float; | ||
exports.string = string; | ||
@@ -111,0 +116,0 @@ exports.word = word; |
@@ -1,128 +0,1 @@ | ||
var asyncGenerator = function () { | ||
function AwaitValue(value) { | ||
this.value = value; | ||
} | ||
function AsyncGenerator(gen) { | ||
var front, back; | ||
function send(key, arg) { | ||
return new Promise(function (resolve, reject) { | ||
var request = { | ||
key: key, | ||
arg: arg, | ||
resolve: resolve, | ||
reject: reject, | ||
next: null | ||
}; | ||
if (back) { | ||
back = back.next = request; | ||
} else { | ||
front = back = request; | ||
resume(key, arg); | ||
} | ||
}); | ||
} | ||
function resume(key, arg) { | ||
try { | ||
var result = gen[key](arg); | ||
var value = result.value; | ||
if (value instanceof AwaitValue) { | ||
Promise.resolve(value.value).then(function (arg) { | ||
resume("next", arg); | ||
}, function (arg) { | ||
resume("throw", arg); | ||
}); | ||
} else { | ||
settle(result.done ? "return" : "normal", result.value); | ||
} | ||
} catch (err) { | ||
settle("throw", err); | ||
} | ||
} | ||
function settle(type, value) { | ||
switch (type) { | ||
case "return": | ||
front.resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
break; | ||
case "throw": | ||
front.reject(value); | ||
break; | ||
default: | ||
front.resolve({ | ||
value: value, | ||
done: false | ||
}); | ||
break; | ||
} | ||
front = front.next; | ||
if (front) { | ||
resume(front.key, front.arg); | ||
} else { | ||
back = null; | ||
} | ||
} | ||
this._invoke = send; | ||
if (typeof gen.return !== "function") { | ||
this.return = undefined; | ||
} | ||
} | ||
if (typeof Symbol === "function" && Symbol.asyncIterator) { | ||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { | ||
return this; | ||
}; | ||
} | ||
AsyncGenerator.prototype.next = function (arg) { | ||
return this._invoke("next", arg); | ||
}; | ||
AsyncGenerator.prototype.throw = function (arg) { | ||
return this._invoke("throw", arg); | ||
}; | ||
AsyncGenerator.prototype.return = function (arg) { | ||
return this._invoke("return", arg); | ||
}; | ||
return { | ||
wrap: function (fn) { | ||
return function () { | ||
return new AsyncGenerator(fn.apply(this, arguments)); | ||
}; | ||
}, | ||
await: function (value) { | ||
return new AwaitValue(value); | ||
} | ||
}; | ||
}(); | ||
var get = function get(object, property, receiver) { | ||
@@ -194,3 +67,3 @@ if (object === null) object = Function.prototype; | ||
}); | ||
exports.date = exports.email = exports.boolean = exports.url = exports.word = exports.string = exports.integer = undefined; | ||
exports.date = exports.email = exports.boolean = exports.url = exports.word = exports.string = exports.float = exports.integer = undefined; | ||
exports.simpleObject = simpleObject; | ||
@@ -216,2 +89,3 @@ exports.objectWithKeys = objectWithKeys; | ||
const integer = exports.integer = options => chance.natural(options); | ||
const float = exports.float = options => chance.floating(options); | ||
const string = exports.string = options => chance.string(options); | ||
@@ -280,2 +154,3 @@ const word = exports.word = () => chance.word(); | ||
integer, | ||
float, | ||
boolean, | ||
@@ -282,0 +157,0 @@ url, |
@@ -130,2 +130,15 @@ # API Reference | ||
## `float` | ||
Direct usage of [`floating()` from chance.js](http://chancejs.com/#floating). Options are passed directly to the chance | ||
method so refer to its documentation for what is available. | ||
### Example | ||
```js | ||
any.float(); | ||
// -114981703621.0176 | ||
``` | ||
## `boolean` | ||
@@ -132,0 +145,0 @@ |
{ | ||
"name": "@travi/any", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "random data generator for when test data is insignificant", | ||
@@ -11,3 +11,5 @@ "main": "dist/any.js", | ||
"prepublish": "grunt build", | ||
"postpublish": "greenkeeper-postpublish" | ||
"postpublish": "greenkeeper-postpublish", | ||
"precommit": "npm test", | ||
"commitmsg": "validate-commit-msg" | ||
}, | ||
@@ -32,3 +34,3 @@ "repository": { | ||
"chance": "1.0.4", | ||
"lodash": "4.16.6" | ||
"lodash": "4.17.2" | ||
}, | ||
@@ -42,3 +44,4 @@ "devDependencies": { | ||
"chai": "3.5.0", | ||
"coveralls": "2.11.14", | ||
"coveralls": "2.11.15", | ||
"cz-conventional-changelog": "1.2.0", | ||
"greenkeeper-postpublish": "1.0.1", | ||
@@ -51,5 +54,6 @@ "grunt": "1.0.1", | ||
"grunt-rollup": "1.0.1", | ||
"husky": "0.11.9", | ||
"istanbul": "1.0.0-alpha.2", | ||
"load-grunt-config": "0.19.2", | ||
"mocha": "3.1.2", | ||
"mocha": "3.2.0", | ||
"proxyquire": "1.7.10", | ||
@@ -59,5 +63,11 @@ "referee": "1.2.0", | ||
"rollup-plugin-babel": "2.6.1", | ||
"sinon": "1.17.6", | ||
"time-grunt": "1.4.0" | ||
"sinon": "2.0.0-pre.4", | ||
"time-grunt": "1.4.0", | ||
"validate-commit-msg": "2.8.2" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
} | ||
} |
@@ -7,3 +7,6 @@ # Random data generator | ||
[![npm](https://img.shields.io/npm/v/@travi/any.svg?maxAge=2592000)](https://www.npmjs.com/package/@travi/any) | ||
[![license](https://img.shields.io/github/license/travi/any.svg)](LICENSE) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
Random data generator for when test data is insignificant. Tailoring data too closely for the domain can end | ||
@@ -10,0 +13,0 @@ up being confusing in tests because it distracts from the behavior that is actually important in the test. This |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
37
0
15754
26
212
+ Addedlodash@4.17.2(transitive)
- Removedlodash@4.16.6(transitive)
Updatedlodash@4.17.2