@travi/any
Advanced tools
Comparing version 1.8.3 to 1.8.4
@@ -9,3 +9,3 @@ 'use strict'; | ||
var defineProperty = function (obj, key, value) { | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
@@ -23,63 +23,30 @@ Object.defineProperty(obj, key, { | ||
return obj; | ||
}; | ||
} | ||
var _extends = Object.assign || function (target) { | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
}; | ||
} | ||
var slicedToArray = function () { | ||
function sliceIterator(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
const debug = require('debug')('any'); | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
const generator = new MersenneTwister(); // Multiply the random seed to match chance.js | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"]) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
const seed = process.env.ANY_SEED || generator.random() * Math.pow(10, 13); | ||
debug(`randomness seed: ${seed}`); | ||
return _arr; | ||
} | ||
return function (arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
} else { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
}; | ||
}(); | ||
var debug = require('debug')('any'); | ||
var generator = new MersenneTwister(); | ||
// Multiply the random seed to match chance.js | ||
var seed = process.env.ANY_SEED || generator.random() * Math.pow(10, 13); | ||
debug('randomness seed: ' + seed); | ||
function isPrimitive(value) { | ||
@@ -89,62 +56,36 @@ return value !== Object(value); | ||
var chance = new Chance(seed); | ||
var integer = function integer(options) { | ||
return chance.natural(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var float = function float(options) { | ||
return chance.floating(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var string = function string(options) { | ||
return chance.string(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var sentence = function sentence(options) { | ||
return chance.sentence(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var paragraph = function paragraph(options) { | ||
return chance.paragraph(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var url = function url(options) { | ||
return chance.url(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var boolean = function boolean(options) { | ||
return chance.bool(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var email = function email(options) { | ||
return chance.email(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var date = function date() { | ||
return chance.date({ string: true }); | ||
}; | ||
var subset = function subset(list) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
_ref$size = _ref.size, | ||
size = _ref$size === undefined ? 2 : _ref$size; | ||
return chance.pickset(list, size); | ||
}; | ||
var fromList = function fromList(list) { | ||
return chance.pickone(list); | ||
}; | ||
function word() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return options.length ? chance.word(options) : chance.word(_extends({ | ||
const chance = new Chance(seed); | ||
const integer = options => chance.natural(!isPrimitive(options) ? options : undefined); | ||
const float = options => chance.floating(!isPrimitive(options) ? options : undefined); | ||
const string = options => chance.string(!isPrimitive(options) ? options : undefined); | ||
const sentence = options => chance.sentence(!isPrimitive(options) ? options : undefined); | ||
const paragraph = options => chance.paragraph(!isPrimitive(options) ? options : undefined); | ||
const url = options => chance.url(!isPrimitive(options) ? options : undefined); | ||
const boolean = options => chance.bool(!isPrimitive(options) ? options : undefined); | ||
const email = options => chance.email(!isPrimitive(options) ? options : undefined); | ||
const date = () => chance.date({ | ||
string: true | ||
}); | ||
const subset = (list, { | ||
size = 2 | ||
} = {}) => chance.pickset(list, size); | ||
const fromList = list => chance.pickone(list); | ||
function word(options = {}) { | ||
return options.length ? chance.word(options) : chance.word(_objectSpread({ | ||
syllables: 3 | ||
}, !isPrimitive(options) ? options : undefined)); | ||
} | ||
const DEFAULT_SIZE_RANGE = { | ||
max: 20, | ||
min: 1 | ||
}; | ||
var DEFAULT_SIZE_RANGE = { max: 20, min: 1 }; | ||
function listOf(factory, options = {}) { | ||
const listSize = options.size || integer(_objectSpread({}, DEFAULT_SIZE_RANGE, options)); | ||
function listOf(factory) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var listSize = options.size || integer(_extends({}, DEFAULT_SIZE_RANGE, options)); | ||
if (options.uniqueOn) { | ||
var uniqueValues = {}; | ||
const uniqueValues = {}; | ||
while (Object.keys(uniqueValues).length < listSize) { | ||
var item = factory(Object.keys(uniqueValues).length); | ||
const item = factory(Object.keys(uniqueValues).length); | ||
uniqueValues[item[options.uniqueOn]] = item; | ||
@@ -156,5 +97,5 @@ } | ||
var list = []; | ||
const list = []; | ||
for (var i = 0; i < listSize; i += 1) { | ||
for (let i = 0; i < listSize; i += 1) { | ||
list.push(factory(i)); | ||
@@ -167,6 +108,6 @@ } | ||
function simpleObject () { | ||
var object = {}; | ||
var size = integer(DEFAULT_SIZE_RANGE); | ||
const object = {}; | ||
const size = integer(DEFAULT_SIZE_RANGE); | ||
for (var i = 0; i < size; i += 1) { | ||
for (let i = 0; i < size; i += 1) { | ||
object[word()] = string(); | ||
@@ -178,32 +119,24 @@ } | ||
function objectWithKeys (keys) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return keys.map(function (key, index) { | ||
return options.factory ? [key, options.factory(key, index)] : [key, string()]; | ||
}).reduce(function (acc, _ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
key = _ref2[0], | ||
value = _ref2[1]; | ||
return _extends({}, acc, defineProperty({}, key, value)); | ||
}, {}); | ||
function objectWithKeys (keys, options = {}) { | ||
return keys.map((key, index) => options.factory ? [key, options.factory(key, index)] : [key, string()]).reduce((acc, [key, value]) => _objectSpread({}, acc, { | ||
[key]: value | ||
}), {}); | ||
} | ||
var index = { | ||
string: string, | ||
word: word, | ||
sentence: sentence, | ||
paragraph: paragraph, | ||
integer: integer, | ||
float: float, | ||
boolean: boolean, | ||
url: url, | ||
email: email, | ||
date: date, | ||
simpleObject: simpleObject, | ||
objectWithKeys: objectWithKeys, | ||
listOf: listOf, | ||
subset: subset, | ||
fromList: fromList | ||
string, | ||
word, | ||
sentence, | ||
paragraph, | ||
integer, | ||
float, | ||
boolean, | ||
url, | ||
email, | ||
date, | ||
simpleObject, | ||
objectWithKeys, | ||
listOf, | ||
subset, | ||
fromList | ||
}; | ||
@@ -210,0 +143,0 @@ |
@@ -5,3 +5,3 @@ import Chance from 'chance'; | ||
var defineProperty = function (obj, key, value) { | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
@@ -19,63 +19,30 @@ Object.defineProperty(obj, key, { | ||
return obj; | ||
}; | ||
} | ||
var _extends = Object.assign || function (target) { | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
}; | ||
} | ||
var slicedToArray = function () { | ||
function sliceIterator(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
const debug = require('debug')('any'); | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
const generator = new MersenneTwister(); // Multiply the random seed to match chance.js | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"]) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
const seed = process.env.ANY_SEED || generator.random() * Math.pow(10, 13); | ||
debug(`randomness seed: ${seed}`); | ||
return _arr; | ||
} | ||
return function (arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
} else { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
}; | ||
}(); | ||
var debug = require('debug')('any'); | ||
var generator = new MersenneTwister(); | ||
// Multiply the random seed to match chance.js | ||
var seed = process.env.ANY_SEED || generator.random() * Math.pow(10, 13); | ||
debug('randomness seed: ' + seed); | ||
function isPrimitive(value) { | ||
@@ -85,62 +52,36 @@ return value !== Object(value); | ||
var chance = new Chance(seed); | ||
var integer = function integer(options) { | ||
return chance.natural(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var float = function float(options) { | ||
return chance.floating(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var string = function string(options) { | ||
return chance.string(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var sentence = function sentence(options) { | ||
return chance.sentence(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var paragraph = function paragraph(options) { | ||
return chance.paragraph(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var url = function url(options) { | ||
return chance.url(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var boolean = function boolean(options) { | ||
return chance.bool(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var email = function email(options) { | ||
return chance.email(!isPrimitive(options) ? options : undefined); | ||
}; | ||
var date = function date() { | ||
return chance.date({ string: true }); | ||
}; | ||
var subset = function subset(list) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
_ref$size = _ref.size, | ||
size = _ref$size === undefined ? 2 : _ref$size; | ||
return chance.pickset(list, size); | ||
}; | ||
var fromList = function fromList(list) { | ||
return chance.pickone(list); | ||
}; | ||
function word() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return options.length ? chance.word(options) : chance.word(_extends({ | ||
const chance = new Chance(seed); | ||
const integer = options => chance.natural(!isPrimitive(options) ? options : undefined); | ||
const float = options => chance.floating(!isPrimitive(options) ? options : undefined); | ||
const string = options => chance.string(!isPrimitive(options) ? options : undefined); | ||
const sentence = options => chance.sentence(!isPrimitive(options) ? options : undefined); | ||
const paragraph = options => chance.paragraph(!isPrimitive(options) ? options : undefined); | ||
const url = options => chance.url(!isPrimitive(options) ? options : undefined); | ||
const boolean = options => chance.bool(!isPrimitive(options) ? options : undefined); | ||
const email = options => chance.email(!isPrimitive(options) ? options : undefined); | ||
const date = () => chance.date({ | ||
string: true | ||
}); | ||
const subset = (list, { | ||
size = 2 | ||
} = {}) => chance.pickset(list, size); | ||
const fromList = list => chance.pickone(list); | ||
function word(options = {}) { | ||
return options.length ? chance.word(options) : chance.word(_objectSpread({ | ||
syllables: 3 | ||
}, !isPrimitive(options) ? options : undefined)); | ||
} | ||
const DEFAULT_SIZE_RANGE = { | ||
max: 20, | ||
min: 1 | ||
}; | ||
var DEFAULT_SIZE_RANGE = { max: 20, min: 1 }; | ||
function listOf(factory, options = {}) { | ||
const listSize = options.size || integer(_objectSpread({}, DEFAULT_SIZE_RANGE, options)); | ||
function listOf(factory) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var listSize = options.size || integer(_extends({}, DEFAULT_SIZE_RANGE, options)); | ||
if (options.uniqueOn) { | ||
var uniqueValues = {}; | ||
const uniqueValues = {}; | ||
while (Object.keys(uniqueValues).length < listSize) { | ||
var item = factory(Object.keys(uniqueValues).length); | ||
const item = factory(Object.keys(uniqueValues).length); | ||
uniqueValues[item[options.uniqueOn]] = item; | ||
@@ -152,5 +93,5 @@ } | ||
var list = []; | ||
const list = []; | ||
for (var i = 0; i < listSize; i += 1) { | ||
for (let i = 0; i < listSize; i += 1) { | ||
list.push(factory(i)); | ||
@@ -163,6 +104,6 @@ } | ||
function simpleObject () { | ||
var object = {}; | ||
var size = integer(DEFAULT_SIZE_RANGE); | ||
const object = {}; | ||
const size = integer(DEFAULT_SIZE_RANGE); | ||
for (var i = 0; i < size; i += 1) { | ||
for (let i = 0; i < size; i += 1) { | ||
object[word()] = string(); | ||
@@ -174,32 +115,24 @@ } | ||
function objectWithKeys (keys) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return keys.map(function (key, index) { | ||
return options.factory ? [key, options.factory(key, index)] : [key, string()]; | ||
}).reduce(function (acc, _ref) { | ||
var _ref2 = slicedToArray(_ref, 2), | ||
key = _ref2[0], | ||
value = _ref2[1]; | ||
return _extends({}, acc, defineProperty({}, key, value)); | ||
}, {}); | ||
function objectWithKeys (keys, options = {}) { | ||
return keys.map((key, index) => options.factory ? [key, options.factory(key, index)] : [key, string()]).reduce((acc, [key, value]) => _objectSpread({}, acc, { | ||
[key]: value | ||
}), {}); | ||
} | ||
var index = { | ||
string: string, | ||
word: word, | ||
sentence: sentence, | ||
paragraph: paragraph, | ||
integer: integer, | ||
float: float, | ||
boolean: boolean, | ||
url: url, | ||
email: email, | ||
date: date, | ||
simpleObject: simpleObject, | ||
objectWithKeys: objectWithKeys, | ||
listOf: listOf, | ||
subset: subset, | ||
fromList: fromList | ||
string, | ||
word, | ||
sentence, | ||
paragraph, | ||
integer, | ||
float, | ||
boolean, | ||
url, | ||
email, | ||
date, | ||
simpleObject, | ||
objectWithKeys, | ||
listOf, | ||
subset, | ||
fromList | ||
}; | ||
@@ -206,0 +139,0 @@ |
{ | ||
"name": "@travi/any", | ||
"version": "1.8.3", | ||
"version": "1.8.4", | ||
"description": "random data generator for when test data is insignificant", | ||
@@ -51,3 +51,3 @@ "main": "lib/any.cjs.js", | ||
"dependencies": { | ||
"chance": "1.0.16", | ||
"chance": "1.0.17", | ||
"debug": "4.1.0", | ||
@@ -58,10 +58,7 @@ "lodash": "4.17.11", | ||
"devDependencies": { | ||
"@travi/eslint-config-travi": "1.6.18", | ||
"babel-cli": "6.26.0", | ||
"babel-plugin-transform-exponentiation-operator": "6.24.1", | ||
"babel-preset-es2015-node": "6.1.1", | ||
"babel-preset-es2015-rollup": "3.0.0", | ||
"babel-preset-stage-3": "6.24.1", | ||
"babel-register": "6.26.0", | ||
"chai": "4.1.2", | ||
"@babel/plugin-transform-exponentiation-operator": "7.1.0", | ||
"@babel/register": "7.0.0", | ||
"@travi/babel-preset": "2.0.0", | ||
"@travi/eslint-config-travi": "1.7.0", | ||
"chai": "4.2.0", | ||
"commitlint-config-travi": "1.2.31", | ||
@@ -72,8 +69,8 @@ "coveralls": "3.0.2", | ||
"globstar": "1.0.0", | ||
"husky": "1.1.3", | ||
"husky": "1.2.0", | ||
"markdown-toc": "1.2.0", | ||
"markdownlint-cli": "0.13.0", | ||
"mocha": "5.2.0", | ||
"npm-run-all": "4.1.3", | ||
"nyc": "13.0.1", | ||
"npm-run-all": "4.1.5", | ||
"nyc": "13.1.0", | ||
"proxyquire": "2.1.0", | ||
@@ -83,5 +80,6 @@ "referee": "1.2.0", | ||
"rimraf": "2.6.2", | ||
"rollup": "0.66.6", | ||
"rollup-plugin-babel": "3.0.7", | ||
"sinon": "6.2.0" | ||
"rollup": "0.67.3", | ||
"rollup-plugin-auto-external": "2.0.0", | ||
"rollup-plugin-babel": "4.0.3", | ||
"sinon": "7.1.1" | ||
}, | ||
@@ -88,0 +86,0 @@ "config": { |
/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */ | ||
import babel from 'rollup-plugin-babel'; | ||
import autoExternal from 'rollup-plugin-auto-external'; | ||
@@ -7,17 +8,10 @@ export default { | ||
plugins: [ | ||
autoExternal(), | ||
babel({ | ||
babelrc: false, | ||
exclude: ['./node_modules/**'], | ||
presets: [ | ||
'es2015-rollup', | ||
'stage-3' | ||
], | ||
plugins: ['babel-plugin-transform-exponentiation-operator'] | ||
presets: ['@travi'], | ||
plugins: ['@babel/plugin-transform-exponentiation-operator'] | ||
}) | ||
], | ||
external: [ | ||
'chance', | ||
'mersenne-twister', | ||
'lodash' | ||
], | ||
output: [ | ||
@@ -24,0 +18,0 @@ {file: 'lib/any.cjs.js', format: 'cjs', sourcemap: true}, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
24
38289
244
1
+ Addedchance@1.0.17(transitive)
- Removedchance@1.0.16(transitive)
Updatedchance@1.0.17