-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Other: Added eventemitter tests and updated micromodule dependencies …
…(so far)
- Loading branch information
Showing
16 changed files
with
121 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
{ | ||
"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", | ||
"url": "https://github.com/dcodeIO/protobuf.js.git" | ||
}, | ||
"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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
/** | ||
* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require("../lib/eventemitter/tests"); |