jrus / random-js Goto Github PK
View Code? Open in Web Editor NEWA port of the Python `random` module to JavaScript
License: Other
A port of the Python `random` module to JavaScript
License: Other
I'm using Random.choice() to select from a list of one or more items generated at random. Quite frequently the lists were of length 1, but the script would stall on the choice. I can work around it by adding a length check, and taking the [0] of the list if it is length 1 and otherwise using choice, but it seems like an issue the library might face a lot.
I think any function that depends upon @_randbelow will suffer from this problem too.
I've already forked and started writing a fix. Is there a test script?
Thanks for making this, I need it!
It doesn't run for me. I tried compiling (coffee -c) and just plain running. Same error (below). Unfortunately I'm a total CoffeeScript/JS newb so I can't provide a helpful bug report. I'm on OSX 10.6.
> coffee --version ~/Documents/dev/coffeescript-tests
CoffeeScript version 1.3.1
> coffee random.coffee ~/Documents/dev/coffeescript-tests
TypeError: In random.coffee, Object
Splat
Value "state" has no method 'isArray'
at Param.names (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:1907:24)
at Code.paramNames (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:1819:39)
at Code.compileNode (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:1708:20)
at Code.compile (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:48:21)
at Assign.compileNode (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:1519:24)
at Assign.compile (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:48:21)
at Block.compileNode (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:311:23)
at Block.compileWithDeclarations (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:395:19)
at Code.compileNode (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:1800:35)
at Code.compile (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/nodes.js:48:21)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.