Code Monkey home page Code Monkey logo

dreamjs's People

Contributors

adleroliveira avatar estrada9166 avatar ramikhalaf avatar yikaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dreamjs's Issues

How to generate object whose key needs to be random ?

for e.g

{
   "587b0cc9-d6e5-40c3-b874-aee034b40001" : {
         name : 'Tom',
         age: 32    
    },

 "232b0cc9-d6e5-40c3-b874-aee034b40001" : {
         name : 'Hilding',
         age: 31    
    }
}

where 587b0cc9-d6e5-40c3-b874-aee034b40001 is guid (a pre-defined chance custom type)

Regards & thanks
Kapil

Improvement to make dreamjs working with karma + PhantomJS + webpack

Hi,

I really want to use dreamjs in my project in order to generate data for testing purposes. However I have this nasty error:

karma start

[2017-02-20 13:31:00.267] [INFO] karma - Karma v1.3.0 server started at http://l
ocalhost:9876/
[2017-02-20 13:31:00.270] [INFO] launcher - Launching browser PhantomJS with unl
imited concurrency
[2017-02-20 13:31:00.274] [INFO] launcher - Starting browser PhantomJS
[2017-02-20 13:31:02.664] [INFO] PhantomJS 2.1.1 (Windows 7 0.0.0) - Connected o
n socket /#vnb5GX37u5VGf7QKAAAA with id 91341862
PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR
SyntaxError: Cannot declare a parameter named 'input' in strict mode
at src/test/js/test-index.js:171070

I was able to fix this error by making 2 changes in dream.js and update the name of variable wherever is used in code:

Line 93: self.input = function input(input) { --> self.input = function input(myinput) {
Line 190: self.schema = function schema(schema) { --> self.schema = function schema(myschema) {

Please if you have time make this change for next release.

how to use dreamjs in website

html:

<script src="bower_components/requirejs/require.js"></script>

js:
var dream = require("bower_components/dreamjs/dream.js")

something error:
Uncaught Error: Module name "bower_components/dreamjs/dream.js" has not been loaded yet for context: _. Use require([])

why promise?

It seems all dreamjs api is not async, how dreamjs use promises in future?

generateRnd not working ?

Maybe i'm missing something. (probably)

In the command line i ran : npm install --save dreamjs

When i follow this example : https://github.com/adleroliveira/dreamjs#generate-and-generaternd i only get empty objects.

Here's my code :

var dream = require('dreamjs');

dream.schema('User', {
  name: String
});

var data1 = dream
  .useSchema('User')
  .generate(3)
  .output();

var data2 = dream
  .useSchema('User')
  .generateRnd(3)
  .output();

console.log(data1); // [ { name: '' }, { name: '' }, { name: '' } ]
console.log(data2); // [ { name: '' }, { name: '' }, { name: '' } ]

I do not understand why names in data2 are empty.

Am i missing something ?

Thanks !

Can you update dreamjs with latest chance version!

Hi! i love dreamjs...
Can you udpate to the latest chance release...

They are new type like 'company'
if we use : dream.schema('workspace', { name: 'company' });
its not working
So for now, i have updated chance to the latest version and use your custom type
dream.customType('company', () => chance.company());
to make it work

Hope you can update!
Thx
Yves L.

callback is called synchronously

Hi @adleroliveira,

Saw this at top of /r/node, congrats!

I noticed that dreamjs supports an async API but its implementation is fully synchronous. This will lead to errors in usage like the following:

dream.output((err, result) => {
  useResult(result);
});
var useResult = () => {
    // do something with result...
}

The async callback model of node guarantees that the callback won't be called until the next turn of the event loop (at the earliest), so the example should be 100% safe.

It looks like your implementation does everything synchronously and calls the callback synchronously too, so the useResult(result); line gets called before useResult is defined, and an error ensues.

More generally, there's no point offering callbacks/Promises/streams if the implementation is synchronous. The synchronous implementation completely starves the event loop until it finishes, so there is no opportunity for other code to run. I would suggest:

  • Either: drop the asynchronous API since it's a fully synchronous implementation
  • Or: change the implementation to break processing into smaller parts which are processed asynchronously by putting them individually on the event loop using eg setImmediate. When the full output is ready, then return the result through the callback/Promise/etc.

As for which is best, I'd say it depends how much processing is likely to be involved in producing deamjs outputs. If it's no more than a millisecond or two in the worst case, you might as well just keep it synchronous.

On the other hand if you get people wanting to generate MBs of test data from this, that could take a while to generate. Your current implementation will starve the event loop even though the API 'looks' asychronous. In this case you should definitely break up the work as suggested above.

Again, nice lib, and that's just my 2c!

Tag releases

It is easier to see what has happened between releases and since the last release, in case there are git tags pushed to the repository.

They are trivial to create afterwards, when knowing the correct commit hashes, for example:

git tag v0.1.7 faaf6b0982a28c0d117f87c3192b37df63d0bc38
git push --tags

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.