[Pkg-javascript-commits] [node-sha.js] 89/237: fake buffer, based on DataView
Bastien Roucariès
rouca at moszumanska.debian.org
Fri May 5 09:03:38 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-sha.js.
commit 71a31b642d3212076dbd9e54cf6b6072b03c61ad
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date: Sat Jan 11 23:13:21 2014 +0700
fake buffer, based on DataView
---
fakebuffer.js | 42 ++++++++++++++++++++++++++++++++++++++++++
sha1.js | 2 +-
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/fakebuffer.js b/fakebuffer.js
new file mode 100644
index 0000000..2d90b01
--- /dev/null
+++ b/fakebuffer.js
@@ -0,0 +1,42 @@
+
+//return module.exports = require('buffer').Buffer
+
+module.exports = function (len) {
+
+ var dv = new DataView(new ArrayBuffer(len))
+
+ dv.writeUInt32BE = function (value, i) {
+ return dv.setUint32(i, value, false)
+ }
+ dv.writeUInt32LE = function (value, i) {
+ return dv.setUint32(i, value, true)
+ }
+
+ dv.readUInt32BE = function (value, i) {
+ return dv.getUint32(i, false)
+ }
+ dv.readUInt32LE = function (value, i) {
+ return dv.getUint32(i, true)
+ }
+
+ dv.writeInt32BE = function (value, i) {
+ return dv.setInt32(i, value, false)
+ }
+ dv.writeInt32LE = function (value, i) {
+ return dv.setInt32(i, value, true)
+ }
+
+ dv.readInt32BE = function (value, i) {
+ return dv.getInt32(i, false)
+ }
+ dv.readInt32LE = function (value, i) {
+ return dv.getInt32(i, true)
+ }
+
+ dv.isBuffer = function (e) {
+ return e instanceof DataView && e.writeUInt32BE
+ }
+
+ return dv
+
+}
diff --git a/sha1.js b/sha1.js
index d003e73..b9aec0c 100644
--- a/sha1.js
+++ b/sha1.js
@@ -12,7 +12,7 @@ var inherits = require('util').inherits
var Hash = require('./hash')
var hexpp = require('./hexpp')
-
+var Buffer = require('./fakebuffer')
inherits(Sha1, Hash)
var A = 0|0
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-sha.js.git
More information about the Pkg-javascript-commits
mailing list