@travi/any
Advanced tools
Comparing version 1.9.0 to 1.9.1
# API Reference | ||
* [`simpleObject`](#simpleobject) | ||
* [`objectWithKeys`](#objectwithkeys) | ||
* [`fromList`](#fromlist) | ||
* [`listOf`](#listof) | ||
* [`string`](#string) | ||
* [`word`](#word) | ||
* [`sentence`](#sentence) | ||
* [`paragraph`](#paragraph) | ||
* [`integer`](#integer) | ||
* [`float`](#float) | ||
* [`boolean`](#boolean) | ||
* [`url`](#url) | ||
* [`email`](#email) | ||
* [`date`](#date) | ||
* [`subset`](#subset) | ||
## Table of Contents | ||
* [simpleObject](#simpleobject) | ||
* [objectWithKeys](#objectwithkeys) | ||
* [fromList](#fromlist) | ||
* [subList](#sublist) | ||
* [listOf](#listof) | ||
* [string](#string) | ||
* [word](#word) | ||
* [sentence](#sentence) | ||
* [paragraph](#paragraph) | ||
* [integer](#integer) | ||
* [float](#float) | ||
* [boolean](#boolean) | ||
* [url](#url) | ||
* [email](#email) | ||
* [date](#date) | ||
* [subset](#subset) | ||
## `simpleObject` | ||
@@ -136,2 +139,21 @@ | ||
## `subList` | ||
An almost direct usage of [`pickset()` from chance.js](http://chancejs.com/helpers/pickset.html). | ||
### `subList` parameters | ||
* `list` (required): list of items to choose from | ||
* `options`: (required) object to provide configuration options | ||
* `size`: (required) length of sub-list that should be produced by choosing | ||
unique items from the provided list | ||
### `subList` example | ||
```js | ||
any.subList(['foo', 'bar', 'baz'], {size: 2}); | ||
// ['bar', 'foo'] | ||
``` | ||
## `listOf` | ||
@@ -143,3 +165,4 @@ | ||
* `factory` (required): the factory function for producing the items for the list. | ||
* `factory` (required): the factory function for producing the items for the | ||
list. | ||
* receives the current index as the first argument | ||
@@ -149,4 +172,4 @@ * `options`: object to provide configuration options | ||
* defaults to a random number between `1` and `20`, if not provided | ||
* the default range of potential sizes can be overridden by providing options | ||
for [integer](#integer) | ||
* the default range of potential sizes can be overridden by providing | ||
options for [integer](#integer) | ||
* `uniqueOn`: property on the produced objects that needs to be unique within | ||
@@ -329,4 +352,4 @@ the resulting list | ||
An almost direct usage of [`pickset()` from chance.js](http://chancejs.com/helpers/pickset.html). | ||
The `size` option is passed directly to the chance method's `quantity` argument so | ||
refer to its documentation for what is available. | ||
The `size` option is passed directly to the chance method's `quantity` argument | ||
so refer to its documentation for what is available. | ||
@@ -333,0 +356,0 @@ ### `subset` parameters |
@@ -70,2 +70,5 @@ 'use strict'; | ||
const fromList = list => chance.pickone(list); | ||
const subList = (list, { | ||
size | ||
}) => chance.pickset(list, size); | ||
function word(options = {}) { | ||
@@ -135,4 +138,5 @@ return options.length ? chance.word(options) : chance.word(_objectSpread({ | ||
listOf, | ||
subset, | ||
fromList | ||
fromList, | ||
subList, | ||
subset | ||
}; | ||
@@ -139,0 +143,0 @@ |
@@ -66,2 +66,5 @@ import Chance from 'chance'; | ||
const fromList = list => chance.pickone(list); | ||
const subList = (list, { | ||
size | ||
}) => chance.pickset(list, size); | ||
function word(options = {}) { | ||
@@ -131,4 +134,5 @@ return options.length ? chance.word(options) : chance.word(_objectSpread({ | ||
listOf, | ||
subset, | ||
fromList | ||
fromList, | ||
subList, | ||
subset | ||
}; | ||
@@ -135,0 +139,0 @@ |
{ | ||
"name": "@travi/any", | ||
"version": "1.9.0", | ||
"version": "1.9.1", | ||
"description": "random data generator for when test data is insignificant", | ||
@@ -10,7 +10,7 @@ "main": "lib/any.cjs.js", | ||
"build": "rollup -c", | ||
"docs:toc": "markdown-toc --no-firsth1 --maxdepth 1 --bullets \"*\" docs/API.md", | ||
"lint:js": "eslint .", | ||
"lint:md": "globstar --node -- markdownlint *.md '**/*.md'", | ||
"lint:md": "remark . --frail", | ||
"tests:unit": "mocha --recursive test/unit/", | ||
"test": "run-s clean lint:* coverage", | ||
"generate:md": "remark . --output", | ||
"coverage": "nyc run-s tests:unit", | ||
@@ -69,4 +69,2 @@ "report-coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"husky": "2.1.0", | ||
"markdown-toc": "1.2.0", | ||
"markdownlint-cli": "0.15.0", | ||
"mocha": "6.1.4", | ||
@@ -78,2 +76,5 @@ "npm-run-all": "4.1.5", | ||
"referee-sinon": "1.0.3", | ||
"remark-cli": "6.0.1", | ||
"remark-preset-lint-travi": "1.2.0", | ||
"remark-toc": "5.1.1", | ||
"rimraf": "2.6.3", | ||
@@ -80,0 +81,0 @@ "rollup": "1.10.1", |
# Random data generator | ||
<!-- status badges --> | ||
[![Build Status](https://img.shields.io/travis/travi/any.svg)](https://travis-ci.org/travi/any) | ||
@@ -34,2 +35,3 @@ [![Coverage Status](http://img.shields.io/coveralls/travi/any.svg)](https://coveralls.io/r/travi/any?branch=master) | ||
<!-- consumer badges --> | ||
[![npm](https://img.shields.io/npm/v/@travi/any.svg?style=flat)](https://www.npmjs.com/package/@travi/any) | ||
@@ -54,2 +56,3 @@ [![monthly downloads](https://img.shields.io/npm/dm/@travi/any.svg?style=flat)](https://www.npmjs.com/package/@travi/any) | ||
<!-- contribution badges --> | ||
[![PRs Welcome][prs-badge]][prs] | ||
@@ -75,2 +78,3 @@ [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) | ||
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg | ||
[prs]: http://makeapullrequest.com |
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
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
39654
261
78
25