[Pkg-javascript-commits] [node-randomfill] 36/47: fix readme
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 15 09:52:54 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-randomfill.
commit db15a1d593408a71be2919b0acf3dd8d75068a94
Author: Calvin Metcalf <cmetcalf at appgeo.com>
Date: Wed Oct 18 10:23:18 2017 -0400
fix readme
---
README.md | 11 ++++++-----
test.js | 16 +++++++++++++++-
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 3bacba4..516ef58 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,15 @@
-randombytes
+randomfill
===
[![Version](http://img.shields.io/npm/v/randombytes.svg)](https://www.npmjs.org/package/randombytes) [![Build Status](https://travis-ci.org/crypto-browserify/randombytes.svg?branch=master)](https://travis-ci.org/crypto-browserify/randombytes)
-randombytes from node that works in the browser. In node you just get crypto.randomBytes, but in the browser it uses .crypto/msCrypto.getRandomValues
+randomfill from node that works in the browser. In node you just get crypto.randomBytes, but in the browser it uses .crypto/msCrypto.getRandomValues
```js
-var randomBytes = require('randombytes');
-randomBytes(16);//get 16 random bytes
-randomBytes(16, function (err, resp) {
+var randomFill = require('randomfill');
+var buf
+randomFill.randomFillSync(16);//get 16 random bytes
+randomFill.randomFill(16, function (err, resp) {
// resp is 16 random bytes
});
```
diff --git a/test.js b/test.js
index 17e897d..d065cd9 100644
--- a/test.js
+++ b/test.js
@@ -1,5 +1,5 @@
var test = require('tape')
-var crypto = require('.')
+var crypto = require('./browser')
test('sync', function (t) {
t.test('first', function (t) {
const buf = Buffer.alloc(10)
@@ -11,3 +11,17 @@ test('sync', function (t) {
t.end()
})
})
+test('async', function (t) {
+ t.test('first', function (t) {
+ const buf = Buffer.alloc(10)
+ const before = buf.toString('hex')
+ crypto.randomFill(buf, 5, 5, function (err, bufa) {
+ t.error(err)
+ const after = bufa.toString('hex')
+ t.notEqual(before, after)
+ t.equal(before.slice(0, 10), after.slice(0, 10))
+ t.ok(buf === bufa, 'same buffer')
+ t.end()
+ })
+ })
+})
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-randomfill.git
More information about the Pkg-javascript-commits
mailing list