Comparing version 1.3.0 to 1.3.1
18
index.js
@@ -1,18 +0,4 @@ | ||
// Generate value using function | ||
var title = casual._title(); | ||
// Equivalent to | ||
var title = casual.title; | ||
var casual = require('./'); | ||
// Pass generator as callback | ||
var array_of = function(times, generator) { | ||
var result = []; | ||
console.log(casual.functions()); | ||
for (var i = 0; i < times; ++i) { | ||
result.push(generator()); | ||
} | ||
return result; | ||
}; | ||
// Will generate array of five random dates | ||
var array_of_dates = array_of(5, casual._date); |
{ | ||
"name": "casual", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Neat fake data generator", | ||
@@ -5,0 +5,0 @@ "main": "src/casual.js", |
@@ -267,6 +267,18 @@ ## Fake data generator [![Build Status](https://travis-ci.org/boo1ean/casual.png?branch=master)](https://travis-ci.org/boo1ean/casual) | ||
// Will generate array of five random dates | ||
var array_of_dates = array_of(5, casual._date); | ||
// Will generate array of five random timestamps | ||
var array_of_timestamps = array_of(5, casual._unix_time); | ||
``` | ||
Or you can get functional version of casual generator: | ||
``` | ||
var casual = require('casual').functions(); | ||
// Generate title | ||
casual.title(); | ||
// Generate text | ||
casual.unix_time(); | ||
``` | ||
## View providers output cli | ||
@@ -273,0 +285,0 @@ |
@@ -5,2 +5,14 @@ var helpers = require('./helpers'); | ||
casual.functions = function() { | ||
var adapter = {}; | ||
Object.keys(this).forEach(function(name) { | ||
if (name[0] === '_') { | ||
adapter[name.slice(1)] = casual[name]; | ||
} | ||
}); | ||
return adapter; | ||
}; | ||
casual.register_provider(require('./providers/text')); | ||
@@ -7,0 +19,0 @@ casual.register_provider(require('./providers/person')); |
@@ -188,2 +188,3 @@ var casual = require('../'); | ||
casual.define('x2', function(x) { | ||
x = x || 2; | ||
return x * 2; | ||
@@ -318,4 +319,24 @@ }); | ||
providers.forEach(check_getters); | ||
}) | ||
}); | ||
it('Should return only funtions interface', function() { | ||
var functions = casual.functions(); | ||
for (var name in functions) { | ||
if (name === 'seed') { | ||
continue; | ||
} | ||
var generator = functions[name]; | ||
var seed = 546; | ||
casual.seed(seed); | ||
var first = casual['_' + name](); | ||
casual.seed(seed); | ||
var second = generator(); | ||
first.should.be.eql(second); | ||
} | ||
}); | ||
}); | ||
}); |
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
109413
1587
317