diff --git a/README.md b/README.md index 50b3ac7..a6d5318 100644 --- a/README.md +++ b/README.md @@ -59,9 +59,52 @@ There are a few utility methods provided by tbd to make generating more random d This is used for selecting a random value from an array: - tbd.from({ foo: 1 }).prop('foo').use(tbd.utils.random(1,2,3,4,5,6,7,8,9)).make(10); + tbd.from({ foo: 1 }) + .prop('foo').use(tbd.utils.random(1,2,3,4,5,6,7,8,9)) + .make(10); //foo's value will be randomly selected from the array for each object created +**tbd.utils.range** + +This is used for randomly choosing a value from a range, similar to the `random` method but simpler as you specify an upper and lower bounds: + + tbd.from({ foo: 1 }) + .prop('foo').use(tbd.utils.range(1, 1000)) + .make(10); + //foo's value will be randomly chosen from a number between 1 and 1000 (inclusive) + +Ranges don't have to be just numbers, they can also be dates: + + tbd.from({ date: new Date }) + .prop('date').use(tbd.utils.range(new Date(2010, 1, 1), new Date())) + .make(10); + //the date propery will be a randomly chosing date between the min and max + +**tbd.utils.sequence** + +This is used for creating a sequential set of data from a starting value: + + tbd.from({ foo: 1 }) + .prop('foo').use(tbd.utils.sequential(1)) + .make(10); + //[0].foo === 1, [9].foo === 10 + +Sequentials support numbers, letters (and words, where the next letter in the alphabet is appended) and dates: + + tbd.from({ date: new Date }) + .prop('foo').use(tbd.utils.sequential(new Date() /* optional parameter for date property the increment, default is 'd' */) + .make(10); + //the 'day' property will be incremented by 1 from the starting value + +Dates allow you to increment any part of the date object (except milliseconds), to do so pass in a 2nd argument: + +* y -> Year +* M -> Month +* d -> Day (default) +* h -> Hour +* m -> Minutes +* s -> Seconds + ## Browser When using tbd in the browser it works exactly the same way, only you don't need the `require` statement (unless you want to use RequireJS).