[Pkg-javascript-commits] [node-bufferjs] 01/03: Imported Upstream version 2.0.0
Thorsten Alteholz
alteholz at moszumanska.debian.org
Fri Feb 19 18:03:05 UTC 2016
This is an automated email from the git hooks/post-receive script.
alteholz pushed a commit to branch master
in repository node-bufferjs.
commit 5014f60204671ae46f9be3b04dc5ca00a31ffac3
Author: Thorsten Alteholz <debian at alteholz.de>
Date: Fri Feb 19 19:02:49 2016 +0100
Imported Upstream version 2.0.0
---
add-chunk.js | 30 ++++++++++++++++++++++++++++++
index.js | 7 +++++++
indexOf.js | 36 ++++++++++++++++++++++++++++++++++++
package.json | 17 +++++++++++++++++
4 files changed, 90 insertions(+)
diff --git a/add-chunk.js b/add-chunk.js
new file mode 100644
index 0000000..89bbf18
--- /dev/null
+++ b/add-chunk.js
@@ -0,0 +1,30 @@
+/*jshint strict:true node:true es5:true onevar:true laxcomma:true laxbreak:true eqeqeq:true immed:true latedef:true*/
+(function () {
+ "use strict";
+
+ Buffer.prototype.__addchunk_index = 0;
+
+ Buffer.prototype.addChunk = function (chunk) {
+ var len = Math.min(chunk.length, this.length - this.__addchunk_index);
+
+ if (this.__addchunk_index === this.length) {
+ //throw new Error("Buffer is full");
+ return false;
+ }
+
+ chunk.copy(this, this.__addchunk_index, 0, len);
+
+ this.__addchunk_index += len;
+
+ if (len < chunk.length) {
+ //remnant = new Buffer(chunk.length - len);
+ //chunk.copy(remnant, 0, len, chunk.length);
+ // return remnant;
+ return chunk.slice(len, chunk.length);
+ }
+
+ if (this.__addchunk_index === this.length) {
+ return true;
+ }
+ };
+}());
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..f41df02
--- /dev/null
+++ b/index.js
@@ -0,0 +1,7 @@
+/*jshint strict:true node:true es5:true onevar:true laxcomma:true laxbreak:true eqeqeq:true immed:true latedef:true*/
+(function () {
+ "use strict";
+
+ require('./add-chunk');
+ require('./indexOf');
+}());
diff --git a/indexOf.js b/indexOf.js
new file mode 100644
index 0000000..896716b
--- /dev/null
+++ b/indexOf.js
@@ -0,0 +1,36 @@
+/*jshint strict:true node:true es5:true onevar:true laxcomma:true laxbreak:true eqeqeq:true immed:true latedef:true*/
+(function () {
+ "use strict";
+
+ /**
+ * A naiive 'Buffer.indexOf' function. Requires both the
+ * needle and haystack to be Buffer instances.
+ */
+ function indexOf(haystack, needle, i) {
+ if (!Buffer.isBuffer(needle)) needle = new Buffer(needle);
+ if (typeof i === 'undefined') i = 0;
+ var l = haystack.length - needle.length + 1;
+ while (i<l) {
+ var good = true;
+ for (var j=0, n=needle.length; j<n; j++) {
+ if (haystack.get(i+j) !== needle.get(j)) {
+ good = false;
+ break;
+ }
+ }
+ if (good) return i;
+ i++;
+ }
+ return -1;
+ }
+
+ if (!Buffer.indexOf) {
+ Buffer.indexOf = indexOf;
+ }
+ if (!Buffer.prototype.indexOf) {
+ Buffer.prototype.indexOf = function(needle, i) {
+ return Buffer.indexOf(this, needle, i);
+ };
+ }
+
+})();
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..3289197
--- /dev/null
+++ b/package.json
@@ -0,0 +1,17 @@
+{
+ "name" : "bufferjs",
+ "description" : "Pure JavaScript Buffer utils.",
+ "url" : "http://github.com/coolaj86/node-bufferjs/",
+ "keywords" : ["util", "buffer", "chunk", "indexOf"],
+ "author" : "AJ ONeal <coolaj86 at gmail.com>",
+ "contributors" : [
+ "Nathan Rajlich <nathan at tootallnate.net>",
+ "Justin Freitag @justinfreitag"
+ ],
+ "dependencies" : {},
+ "version" : "2.0.0",
+ "main" : "./index",
+ "engines" : {
+ "node" : ">=0.2.0"
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-bufferjs.git
More information about the Pkg-javascript-commits
mailing list