mirror of
https://github.com/protobufjs/protobuf.js.git
synced 2025-12-08 20:58:55 +00:00
Other: Added eventemitter tests and updated micromodule dependencies (so far)
This commit is contained in:
parent
2db4305ca6
commit
3fcd88c3f9
2
lib/aspromise/index.d.ts
vendored
2
lib/aspromise/index.d.ts
vendored
@ -8,4 +8,4 @@ export = asPromise;
|
||||
* @param {...*} params Function arguments
|
||||
* @returns {Promise<*>} Promisified function
|
||||
*/
|
||||
function asPromise(fn: () => any, ctx: any, ...params: any[]): Promise<any>;
|
||||
declare function asPromise(fn: () => any, ctx: any, ...params: any[]): Promise<any>;
|
||||
|
||||
@ -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 <dcode+protobufjs@dcode.io>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@ -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) {
|
||||
|
||||
64
lib/base64/index.d.ts
vendored
64
lib/base64/index.d.ts
vendored
@ -1,42 +1,32 @@
|
||||
export = base64;
|
||||
/**
|
||||
* Calculates the byte length of a base64 encoded string.
|
||||
* @param {string} string Base64 encoded string
|
||||
* @returns {number} Byte length
|
||||
*/
|
||||
export function length(string: string): number;
|
||||
|
||||
/**
|
||||
* A minimal base64 implementation for number arrays.
|
||||
* @memberof util
|
||||
* @namespace
|
||||
* 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
|
||||
*/
|
||||
declare namespace base64 {
|
||||
export function encode(buffer: Uint8Array, start: number, end: number): string;
|
||||
|
||||
/**
|
||||
* Calculates the byte length of a base64 encoded string.
|
||||
* @param {string} string Base64 encoded string
|
||||
* @returns {number} Byte length
|
||||
*/
|
||||
function length(string: string): 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@ -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 <dcode+protobufjs@dcode.io>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@protobufjs/eventemitter",
|
||||
"description": "A minimal event emitter.",
|
||||
"version": "1.0.5",
|
||||
"version": "1.1.0",
|
||||
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
47
lib/eventemitter/tests/index.js
Normal file
47
lib/eventemitter/tests/index.js
Normal file
@ -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();
|
||||
});
|
||||
@ -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",
|
||||
|
||||
@ -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 <dcode+protobufjs@dcode.io>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
46
lib/path/index.d.ts
vendored
46
lib/path/index.d.ts
vendored
@ -1,32 +1,22 @@
|
||||
export = path;
|
||||
/**
|
||||
* Tests if the specified path is absolute.
|
||||
* @param {string} path Path to test
|
||||
* @returns {boolean} `true` if path is absolute
|
||||
*/
|
||||
export function isAbsolute(path: string): boolean;
|
||||
|
||||
/**
|
||||
* A minimal path module to resolve Unix, Windows and URL paths alike.
|
||||
* @memberof util
|
||||
* @namespace
|
||||
* Normalizes the specified path.
|
||||
* @param {string} path Path to normalize
|
||||
* @returns {string} Normalized path
|
||||
*/
|
||||
declare namespace path {
|
||||
export function normalize(path: string): string;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Normalizes the specified path.
|
||||
* @param {string} path Path to normalize
|
||||
* @returns {string} Normalized path
|
||||
*/
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@ -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 <dcode+protobufjs@dcode.io>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@protobufjs/pool",
|
||||
"description": "A general purpose buffer pool.",
|
||||
"version": "1.0.6",
|
||||
"version": "1.1.0",
|
||||
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 <dcode+protobufjs@dcode.io>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
14
package.json
14
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",
|
||||
|
||||
1
tests/lib_eventemitter.js
Normal file
1
tests/lib_eventemitter.js
Normal file
@ -0,0 +1 @@
|
||||
require("../lib/eventemitter/tests");
|
||||
Loading…
x
Reference in New Issue
Block a user