diff --git a/lib/aspromise/index.d.ts b/lib/aspromise/index.d.ts index 5e73140ea..b9166dc77 100644 --- a/lib/aspromise/index.d.ts +++ b/lib/aspromise/index.d.ts @@ -8,4 +8,4 @@ export = asPromise; * @param {...*} params Function arguments * @returns {Promise<*>} Promisified function */ -function asPromise(fn: () => any, ctx: any, ...params: any[]): Promise; +declare function asPromise(fn: () => any, ctx: any, ...params: any[]): Promise; diff --git a/lib/aspromise/package.json b/lib/aspromise/package.json index 430dc6e62..45d335a2b 100644 --- a/lib/aspromise/package.json +++ b/lib/aspromise/package.json @@ -1,7 +1,7 @@ { "name": "@protobufjs/aspromise", "description": "Returns a promise from a node-style callback function.", - "version": "1.0.6", + "version": "1.1.1", "author": "Daniel Wirtz ", "repository": { "type": "git", diff --git a/lib/aspromise/tests/index.js b/lib/aspromise/tests/index.js index f318d5f0f..e6c1ef80a 100644 --- a/lib/aspromise/tests/index.js +++ b/lib/aspromise/tests/index.js @@ -2,11 +2,9 @@ var tape = require("tape"); var asPromise = require(".."); +if (typeof Promise !== "undefined") tape.test("aspromise", function(test) { - if (typeof Promise === "undefined") - return test.pass("not supported, skipping..."); - test.test(this.name + " - resolve", function(test) { function fn(arg1, arg2, callback) { diff --git a/lib/base64/index.d.ts b/lib/base64/index.d.ts index 53f58b95a..085d0a7a0 100644 --- a/lib/base64/index.d.ts +++ b/lib/base64/index.d.ts @@ -1,42 +1,32 @@ -export = base64; - /** - * A minimal base64 implementation for number arrays. - * @memberof util - * @namespace + * Calculates the byte length of a base64 encoded string. + * @param {string} string Base64 encoded string + * @returns {number} Byte length */ -declare namespace base64 { - - /** - * Calculates the byte length of a base64 encoded string. - * @param {string} string Base64 encoded string - * @returns {number} Byte length - */ - function length(string: string): number; +export function length(string: string): number; - /** - * Encodes a buffer to a base64 encoded string. - * @param {Uint8Array} buffer Source buffer - * @param {number} start Source start - * @param {number} end Source end - * @returns {string} Base64 encoded string - */ - function encode(buffer: Uint8Array, start: number, end: number): string; +/** + * Encodes a buffer to a base64 encoded string. + * @param {Uint8Array} buffer Source buffer + * @param {number} start Source start + * @param {number} end Source end + * @returns {string} Base64 encoded string + */ +export function encode(buffer: Uint8Array, start: number, end: number): string; - /** - * Decodes a base64 encoded string to a buffer. - * @param {string} string Source string - * @param {Uint8Array} buffer Destination buffer - * @param {number} offset Destination offset - * @returns {number} Number of bytes written - * @throws {Error} If encoding is invalid - */ - function decode(string: string, buffer: Uint8Array, offset: number): number; +/** + * Decodes a base64 encoded string to a buffer. + * @param {string} string Source string + * @param {Uint8Array} buffer Destination buffer + * @param {number} offset Destination offset + * @returns {number} Number of bytes written + * @throws {Error} If encoding is invalid + */ +export function decode(string: string, buffer: Uint8Array, offset: number): number; - /** - * Tests if the specified string appears to be base64 encoded. - * @param {string} string String to test - * @returns {boolean} `true` if it appears to be base64 encoded, otherwise false - */ - function test(string: string): boolean; -} +/** + * Tests if the specified string appears to be base64 encoded. + * @param {string} string String to test + * @returns {boolean} `true` if it appears to be base64 encoded, otherwise false + */ +export function test(string: string): boolean; diff --git a/lib/base64/package.json b/lib/base64/package.json index d93984226..7eba6d44e 100644 --- a/lib/base64/package.json +++ b/lib/base64/package.json @@ -1,7 +1,7 @@ { "name": "@protobufjs/base64", "description": "A minimal base64 implementation for number arrays.", - "version": "1.0.6", + "version": "1.1.1", "author": "Daniel Wirtz ", "repository": { "type": "git", diff --git a/lib/eventemitter/package.json b/lib/eventemitter/package.json index ff40404ff..b333e9970 100644 --- a/lib/eventemitter/package.json +++ b/lib/eventemitter/package.json @@ -1,7 +1,7 @@ { "name": "@protobufjs/eventemitter", "description": "A minimal event emitter.", - "version": "1.0.5", + "version": "1.1.0", "author": "Daniel Wirtz ", "repository": { "type": "git", @@ -9,5 +9,13 @@ }, "license": "BSD-3-Clause", "main": "index.js", - "types": "index.d.ts" + "types": "index.d.ts", + "devDependencies": { + "istanbul": "^0.4.5", + "tape": "^4.6.3" + }, + "scripts": { + "test": "tape tests/*.js", + "coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js" + } } \ No newline at end of file diff --git a/lib/eventemitter/tests/index.js b/lib/eventemitter/tests/index.js new file mode 100644 index 000000000..390958fd8 --- /dev/null +++ b/lib/eventemitter/tests/index.js @@ -0,0 +1,47 @@ +var tape = require("tape"); + +var EventEmitter = require(".."); + +tape.test("eventemitter", function(test) { + + var ee = new EventEmitter(); + var fn; + var ctx = {}; + + test.doesNotThrow(function() { + ee.emit("a", 1); + ee.off(); + ee.off("a"); + ee.off("a", function() {}); + }, "should not throw if no listeners are registered"); + + test.equal(ee.on("a", function(arg1) { + test.equal(this, ctx, "should be called with this = ctx"); + test.equal(arg1, 1, "should be called with arg1 = 1"); + }, ctx), ee, "should return itself when registering events"); + ee.emit("a", 1); + + ee.off("a"); + test.same(ee._listeners, { a: [] }, "should remove all listeners of the respective event when calling off(evt)"); + + ee.off(); + test.same(ee._listeners, {}, "should remove all listeners when just calling off()"); + + ee.on("a", fn = function(arg1) { + test.equal(this, ctx, "should be called with this = ctx"); + test.equal(arg1, 1, "should be called with arg1 = 1"); + }, ctx).emit("a", 1); + + ee.off("a", fn); + test.same(ee._listeners, { a: [] }, "should remove the exact listener when calling off(evt, fn)"); + + ee.on("a", function() { + test.equal(this, ee, "should be called with this = ee"); + }).emit("a"); + + test.doesNotThrow(function() { + ee.off("a", fn); + }, "should not throw if no such listener is found"); + + test.end(); +}); diff --git a/lib/fetch/package.json b/lib/fetch/package.json index a2f1437a1..f84524060 100644 --- a/lib/fetch/package.json +++ b/lib/fetch/package.json @@ -8,8 +8,8 @@ "url": "https://github.com/dcodeIO/protobuf.js.git" }, "dependencies": { - "@protobufjs/aspromise": "^1.0.5", - "@protobufjs/inquire": "^1.0.2" + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" }, "license": "BSD-3-Clause", "main": "index.js", diff --git a/lib/inquire/package.json b/lib/inquire/package.json index 85a1bf5d1..6a64d665b 100644 --- a/lib/inquire/package.json +++ b/lib/inquire/package.json @@ -1,7 +1,7 @@ { "name": "@protobufjs/inquire", "description": "Requires a module only if available and hides the require call from bundlers.", - "version": "1.0.3", + "version": "1.1.0", "author": "Daniel Wirtz ", "repository": { "type": "git", diff --git a/lib/path/index.d.ts b/lib/path/index.d.ts index 2222b306c..b664d81f6 100644 --- a/lib/path/index.d.ts +++ b/lib/path/index.d.ts @@ -1,32 +1,22 @@ -export = path; - /** - * A minimal path module to resolve Unix, Windows and URL paths alike. - * @memberof util - * @namespace + * Tests if the specified path is absolute. + * @param {string} path Path to test + * @returns {boolean} `true` if path is absolute */ -declare namespace path { - - /** - * Tests if the specified path is absolute. - * @param {string} path Path to test - * @returns {boolean} `true` if path is absolute - */ - function isAbsolute(path: string): boolean; +export function isAbsolute(path: string): boolean; - /** - * Normalizes the specified path. - * @param {string} path Path to normalize - * @returns {string} Normalized path - */ - function normalize(path: string): string; +/** + * Normalizes the specified path. + * @param {string} path Path to normalize + * @returns {string} Normalized path + */ +export function normalize(path: string): string; - /** - * Resolves the specified include path against the specified origin path. - * @param {string} originPath Path to the origin file - * @param {string} includePath Include path relative to origin path - * @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized - * @returns {string} Path to the include file - */ - function resolve(originPath: string, includePath: string, alreadyNormalized?: boolean): string; -} \ No newline at end of file +/** + * Resolves the specified include path against the specified origin path. + * @param {string} originPath Path to the origin file + * @param {string} includePath Include path relative to origin path + * @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized + * @returns {string} Path to the include file + */ +export function resolve(originPath: string, includePath: string, alreadyNormalized?: boolean): string; diff --git a/lib/path/package.json b/lib/path/package.json index 92d4d4942..593576df8 100644 --- a/lib/path/package.json +++ b/lib/path/package.json @@ -1,7 +1,7 @@ { "name": "@protobufjs/path", "description": "A minimal path module to resolve Unix, Windows and URL paths alike.", - "version": "1.0.3", + "version": "1.1.1", "author": "Daniel Wirtz ", "repository": { "type": "git", diff --git a/lib/pool/package.json b/lib/pool/package.json index c4db6f0e2..f025e033a 100644 --- a/lib/pool/package.json +++ b/lib/pool/package.json @@ -1,7 +1,7 @@ { "name": "@protobufjs/pool", "description": "A general purpose buffer pool.", - "version": "1.0.6", + "version": "1.1.0", "author": "Daniel Wirtz ", "repository": { "type": "git", diff --git a/lib/pool/tests/index.js b/lib/pool/tests/index.js index d81a639d9..5d1a921fe 100644 --- a/lib/pool/tests/index.js +++ b/lib/pool/tests/index.js @@ -2,11 +2,9 @@ var tape = require("tape"); var pool = require(".."); +if (typeof Uint8Array !== "undefined") tape.test("pool", function(test) { - if (typeof Uint8Array === "undefined") - return test.pass("not supported, skipping..."); - var alloc = pool(function(size) { return new Uint8Array(size); }, Uint8Array.prototype.subarray); var buf1 = alloc(0); diff --git a/lib/utf8/package.json b/lib/utf8/package.json index 16ff7235b..80881c51a 100644 --- a/lib/utf8/package.json +++ b/lib/utf8/package.json @@ -1,7 +1,7 @@ { "name": "@protobufjs/utf8", "description": "A minimal UTF8 implementation for number arrays.", - "version": "1.0.8", + "version": "1.1.0", "author": "Daniel Wirtz ", "repository": { "type": "git", diff --git a/package.json b/package.json index 3ecb76519..143cb12df 100644 --- a/package.json +++ b/package.json @@ -45,15 +45,15 @@ "release": "npm run make && npm run changelog" }, "dependencies": { - "@protobufjs/aspromise": "^1.0.5", - "@protobufjs/base64": "^1.0.5", + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/base64": "^1.1.1", "@protobufjs/codegen": "^1.0.8", - "@protobufjs/eventemitter": "^1.0.5", + "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.0.4", - "@protobufjs/inquire": "^1.0.2", - "@protobufjs/path": "^1.0.2", - "@protobufjs/pool": "^1.0.5", - "@protobufjs/utf8": "^1.0.7" + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.1", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0" }, "optionalDependencies": { "long": "^3.2.0", diff --git a/tests/lib_eventemitter.js b/tests/lib_eventemitter.js new file mode 100644 index 000000000..bbd0cca08 --- /dev/null +++ b/tests/lib_eventemitter.js @@ -0,0 +1 @@ +require("../lib/eventemitter/tests");