Giter Site home page Giter Site logo

node-srand's Introduction

srand for node

var srand = require('srand');

// Seed the random
srand.seed(Date.now());

// Mimic JS Math.random
srand.random();

// C rand()
srand.rand();

node-srand's People

Contributors

arasmussen avatar daquirm avatar dtaniwaki avatar isaacs avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

node-srand's Issues

Failed to build on [email protected]

Attaching node-gyp error log

> [email protected] install /Users/redism/dev/sandbox/node-srand
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
2015-01-17 11:28:11.754 xcodebuild[56303:1007] [MT] PluginLoading: Required plug-in compatibility UUID C4A681B0-4A26-480E-93EC-1218098B9AA0 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Unity4XC.xcplugin' not present in DVTPlugInCompatibilityUUIDs
  CXX(target) Release/obj.target/srand/srand.o
../srand.cc:9:36: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
static Handle<Value> Random (const Arguments&);
                                   ^~~~~~~~~
                                   v8::internal::Arguments
/Users/redism/.node-gyp/1.0.2/deps/v8/include/v8.h:133:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
../srand.cc:10:34: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
static Handle<Value> Rand (const Arguments&);
                                 ^~~~~~~~~
                                 v8::internal::Arguments
/Users/redism/.node-gyp/1.0.2/deps/v8/include/v8.h:133:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
../srand.cc:11:35: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
static Handle<Value> SRand (const Arguments&);
                                  ^~~~~~~~~
                                  v8::internal::Arguments
/Users/redism/.node-gyp/1.0.2/deps/v8/include/v8.h:133:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
../srand.cc:14:36: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
static Handle<Value> Random (const Arguments& args) {
                                   ^~~~~~~~~
                                   v8::internal::Arguments
/Users/redism/.node-gyp/1.0.2/deps/v8/include/v8.h:133:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
../srand.cc:15:51: error: too few arguments to function call, expected 2, have 1
  return Number::New(rand()/((double)RAND_MAX + 1));
         ~~~~~~~~~~~                              ^
/Users/redism/.node-gyp/1.0.2/deps/v8/include/v8.h:2291:3: note: 'New' declared here
  static Local<Number> New(Isolate* isolate, double value);
  ^
../srand.cc:18:34: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
static Handle<Value> Rand (const Arguments& args) {
                                 ^~~~~~~~~
                                 v8::internal::Arguments
/Users/redism/.node-gyp/1.0.2/deps/v8/include/v8.h:133:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
../srand.cc:19:29: error: too few arguments to function call, expected 2, have 1
  return Integer::New(rand());
         ~~~~~~~~~~~~       ^
/Users/redism/.node-gyp/1.0.2/deps/v8/include/v8.h:2304:3: note: 'New' declared here
  static Local<Integer> New(Isolate* isolate, int32_t value);
  ^
../srand.cc:22:35: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
static Handle<Value> SRand (const Arguments& args) {
                                  ^~~~~~~~~
                                  v8::internal::Arguments
/Users/redism/.node-gyp/1.0.2/deps/v8/include/v8.h:133:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
../srand.cc:23:11: error: member access into incomplete type 'const v8::internal::Arguments'
  if (args.Length() == 0) {
          ^
/Users/redism/.node-gyp/1.0.2/deps/v8/include/v8.h:133:7: note: forward declaration of 'v8::internal::Arguments'
class Arguments;
      ^
../srand.cc:24:52: error: no member named 'New' in 'v8::String'
    return ThrowException(Exception::Error(String::New("Usage: srand(n)")));
                                           ~~~~~~~~^
../srand.cc:26:13: error: type 'const v8::internal::Arguments' does not provide a subscript operator
  srand(args[0]->Uint32Value());
        ~~~~^~
../srand.cc:27:10: error: no matching function for call to 'Undefined'
  return Undefined();
         ^~~~~~~~~
/Users/redism/.node-gyp/1.0.2/deps/v8/include/v8.h:323:28: note: candidate function not viable: requires single argument
      'isolate', but no arguments were provided
  friend Handle<Primitive> Undefined(Isolate* isolate);
                           ^
../srand.cc:31:15: error: calling a protected constructor of class 'v8::HandleScope'
  HandleScope scope;
              ^
/Users/redism/.node-gyp/1.0.2/deps/v8/include/v8.h:878:13: note: declared protected here
  V8_INLINE HandleScope() {}
            ^
../srand.cc:32:3: error: no matching function for call to 'NODE_SET_METHOD'
  NODE_SET_METHOD(target, "random", Random);
  ^~~~~~~~~~~~~~~
/Users/redism/.node-gyp/1.0.2/src/node.h:212:25: note: expanded from macro 'NODE_SET_METHOD'
#define NODE_SET_METHOD node::NODE_SET_METHOD
                        ^~~~~~~~~~~~~~~~~~~~~
/Users/redism/.node-gyp/1.0.2/src/node.h:200:13: note: candidate function [with TypeName = v8::Handle<v8::Object>] not viable:
      no known conversion from 'Handle<v8::Value> (const v8::internal::Arguments &)' to 'v8::FunctionCallback' (aka 'void
      (*)(const FunctionCallbackInfo<v8::Value> &)') for 3rd argument
inline void NODE_SET_METHOD(const TypeName& recv,
            ^
../srand.cc:33:3: error: no matching function for call to 'NODE_SET_METHOD'
  NODE_SET_METHOD(target, "rand", Rand);
  ^~~~~~~~~~~~~~~
/Users/redism/.node-gyp/1.0.2/src/node.h:212:25: note: expanded from macro 'NODE_SET_METHOD'
#define NODE_SET_METHOD node::NODE_SET_METHOD
                        ^~~~~~~~~~~~~~~~~~~~~
/Users/redism/.node-gyp/1.0.2/src/node.h:200:13: note: candidate function [with TypeName = v8::Handle<v8::Object>] not viable:
      no known conversion from 'Handle<v8::Value> (const v8::internal::Arguments &)' to 'v8::FunctionCallback' (aka 'void
      (*)(const FunctionCallbackInfo<v8::Value> &)') for 3rd argument
inline void NODE_SET_METHOD(const TypeName& recv,
            ^
../srand.cc:34:3: error: no matching function for call to 'NODE_SET_METHOD'
  NODE_SET_METHOD(target, "srand", SRand);
  ^~~~~~~~~~~~~~~
/Users/redism/.node-gyp/1.0.2/src/node.h:212:25: note: expanded from macro 'NODE_SET_METHOD'
#define NODE_SET_METHOD node::NODE_SET_METHOD
                        ^~~~~~~~~~~~~~~~~~~~~
/Users/redism/.node-gyp/1.0.2/src/node.h:200:13: note: candidate function [with TypeName = v8::Handle<v8::Object>] not viable:
      no known conversion from 'Handle<v8::Value> (const v8::internal::Arguments &)' to 'v8::FunctionCallback' (aka 'void
      (*)(const FunctionCallbackInfo<v8::Value> &)') for 3rd argument
inline void NODE_SET_METHOD(const TypeName& recv,
            ^
../srand.cc:35:3: error: no matching function for call to 'NODE_SET_METHOD'
  NODE_SET_METHOD(target, "seed", SRand);
  ^~~~~~~~~~~~~~~
/Users/redism/.node-gyp/1.0.2/src/node.h:212:25: note: expanded from macro 'NODE_SET_METHOD'
#define NODE_SET_METHOD node::NODE_SET_METHOD
                        ^~~~~~~~~~~~~~~~~~~~~
/Users/redism/.node-gyp/1.0.2/src/node.h:200:13: note: candidate function [with TypeName = v8::Handle<v8::Object>] not viable:
      no known conversion from 'Handle<v8::Value> (const v8::internal::Arguments &)' to 'v8::FunctionCallback' (aka 'void
      (*)(const FunctionCallbackInfo<v8::Value> &)') for 3rd argument
inline void NODE_SET_METHOD(const TypeName& recv,
            ^
17 errors generated.
make: *** [Release/obj.target/srand/srand.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1038:12)
gyp ERR! System Darwin 13.4.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/redism/dev/sandbox/node-srand
gyp ERR! node -v v1.0.2
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok

npm ERR! Darwin 13.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v1.0.2
npm ERR! npm  v2.1.18
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the srand package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls srand
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/redism/dev/sandbox/node-srand/npm-debug.log

npm install fails

on Mac OS 10.6.8
with npm 1.1.4 and node.js 0.6.12

npm install srand fails

npm http GET https://registry.npmjs.org/srand
npm http 304 https://registry.npmjs.org/srand

> [email protected] preinstall /Users/carlos/t/node_modules/srand
> node-waf clean || (exit 0); node-waf configure build

Nothing to clean (project not configured)
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local 
'configure' finished successfully (0.046s)
Waf: Entering directory `/Users/isaacs/dev/js/srand/build'
Waf: Leaving directory `/Users/isaacs/dev/js/srand/build'
Traceback (most recent call last):
  File "/usr/local/bin/node-waf", line 16, in 
    Scripting.prepare(t, os.getcwd(), VERSION, wafdir)
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 145, in prepare
    prepare_impl(t, cwd, ver, wafdir)
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 135, in prepare_impl
    main()
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 188, in main
    fun(ctx)
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 386, in build
    return build_impl(bld)
  File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 405, in build_impl
    bld.compile()
  File "/usr/local/bin/../lib/node/wafadmin/Build.py", line 268, in compile
    os.chdir(self.bldnode.abspath())
OSError: [Errno 2] No such file or directory: '/Users/isaacs/dev/js/srand/build'
npm ERR! error installing [email protected]

npm ERR! [email protected] preinstall: `node-waf clean || (exit 0); node-waf configure build`
npm ERR! `sh "-c" "node-waf clean || (exit 0); node-waf configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the srand package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf clean || (exit 0); node-waf configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls srand
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Darwin 10.8.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "srand"
npm ERR! cwd /Users/carlos/t
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] preinstall: `node-waf clean || (exit 0); node-waf configure build`
npm ERR! message `sh "-c" "node-waf clean || (exit 0); node-waf configure build"` failed with 1
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/carlos/t/npm-debug.log
npm not ok

However, npm install inside node-srand works.
Perhaps a problem publishing to npm?

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.