diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:43:05 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 22:18:30 +0800 |
| commit | 89e95b3f143682ed9a006991bacf45c9dcba4818 (patch) | |
| tree | 4f44cf41b828577d583890bdd5a1c31e8491a6ba /node_modules/tiny-emitter | |
| parent | aa7f0199255277949790b41c56e8ec97dd4f0da4 (diff) | |
| download | xmake-docs-vuepress.tar.gz xmake-docs-vuepress.zip | |
remove node_modulesvuepress
Diffstat (limited to 'node_modules/tiny-emitter')
| -rw-r--r-- | node_modules/tiny-emitter/.npmignore | 14 | ||||
| -rw-r--r-- | node_modules/tiny-emitter/LICENSE | 22 | ||||
| -rw-r--r-- | node_modules/tiny-emitter/README.md | 88 | ||||
| -rw-r--r-- | node_modules/tiny-emitter/dist/tinyemitter.js | 70 | ||||
| -rw-r--r-- | node_modules/tiny-emitter/dist/tinyemitter.min.js | 1 | ||||
| -rw-r--r-- | node_modules/tiny-emitter/index.d.ts | 8 | ||||
| -rw-r--r-- | node_modules/tiny-emitter/index.js | 66 | ||||
| -rw-r--r-- | node_modules/tiny-emitter/instance.js | 2 | ||||
| -rw-r--r-- | node_modules/tiny-emitter/package.json | 53 | ||||
| -rw-r--r-- | node_modules/tiny-emitter/test/index.js | 217 |
10 files changed, 0 insertions, 541 deletions
diff --git a/node_modules/tiny-emitter/.npmignore b/node_modules/tiny-emitter/.npmignore deleted file mode 100644 index 6580b973..00000000 --- a/node_modules/tiny-emitter/.npmignore +++ /dev/null @@ -1,14 +0,0 @@ -lib-cov -*.seed -*.log -*.csv -*.dat -*.out -*.pid -*.gz -pids -logs -results -npm-debug.log -node_modules -.idea
\ No newline at end of file diff --git a/node_modules/tiny-emitter/LICENSE b/node_modules/tiny-emitter/LICENSE deleted file mode 100644 index 24f10246..00000000 --- a/node_modules/tiny-emitter/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2017 Scott Corgan - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/node_modules/tiny-emitter/README.md b/node_modules/tiny-emitter/README.md deleted file mode 100644 index cd474cd0..00000000 --- a/node_modules/tiny-emitter/README.md +++ /dev/null @@ -1,88 +0,0 @@ -# tiny-emitter - -A tiny (less than 1k) event emitter library. - -## Install - -### npm - -``` -npm install tiny-emitter --save -``` - -## Usage - -```js -var Emitter = require('tiny-emitter'); -var emitter = new Emitter(); - -emitter.on('some-event', function (arg1, arg2, arg3) { - // -}); - -emitter.emit('some-event', 'arg1 value', 'arg2 value', 'arg3 value'); -``` - -Alternatively, you can skip the initialization step by requiring `tiny-emitter/instance` instead. This pulls in an already initialized emitter. - -```js -var emitter = require('tiny-emitter/instance'); - -emitter.on('some-event', function (arg1, arg2, arg3) { - // -}); - -emitter.emit('some-event', 'arg1 value', 'arg2 value', 'arg3 value'); -``` - -## Instance Methods - -### on(event, callback[, context]) - -Subscribe to an event - -* `event` - the name of the event to subscribe to -* `callback` - the function to call when event is emitted -* `context` - (OPTIONAL) - the context to bind the event callback to - -### once(event, callback[, context]) - -Subscribe to an event only **once** - -* `event` - the name of the event to subscribe to -* `callback` - the function to call when event is emitted -* `context` - (OPTIONAL) - the context to bind the event callback to - -### off(event[, callback]) - -Unsubscribe from an event or all events. If no callback is provided, it unsubscribes you from all events. - -* `event` - the name of the event to unsubscribe from -* `callback` - the function used when binding to the event - -### emit(event[, arguments...]) - -Trigger a named event - -* `event` - the event name to emit -* `arguments...` - any number of arguments to pass to the event subscribers - -## Test and Build - -Build (Tests, Browserifies, and minifies) - -``` -npm install -npm run build -``` - -Test - -``` -npm install -npm test -``` - -## License - -[MIT](https://github.com/scottcorgan/tiny-emitter/blob/master/LICENSE) diff --git a/node_modules/tiny-emitter/dist/tinyemitter.js b/node_modules/tiny-emitter/dist/tinyemitter.js deleted file mode 100644 index 956acb2e..00000000 --- a/node_modules/tiny-emitter/dist/tinyemitter.js +++ /dev/null @@ -1,70 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.TinyEmitter = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ -function E () { - // Keep this empty so it's easier to inherit from - // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) -} - -E.prototype = { - on: function (name, callback, ctx) { - var e = this.e || (this.e = {}); - - (e[name] || (e[name] = [])).push({ - fn: callback, - ctx: ctx - }); - - return this; - }, - - once: function (name, callback, ctx) { - var self = this; - function listener () { - self.off(name, listener); - callback.apply(ctx, arguments); - }; - - listener._ = callback - return this.on(name, listener, ctx); - }, - - emit: function (name) { - var data = [].slice.call(arguments, 1); - var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); - var i = 0; - var len = evtArr.length; - - for (i; i < len; i++) { - evtArr[i].fn.apply(evtArr[i].ctx, data); - } - - return this; - }, - - off: function (name, callback) { - var e = this.e || (this.e = {}); - var evts = e[name]; - var liveEvents = []; - - if (evts && callback) { - for (var i = 0, len = evts.length; i < len; i++) { - if (evts[i].fn !== callback && evts[i].fn._ !== callback) - liveEvents.push(evts[i]); - } - } - - // Remove event from queue to prevent memory leak - // Suggested by https://github.com/lazd - // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 - - (liveEvents.length) - ? e[name] = liveEvents - : delete e[name]; - - return this; - } -}; - -module.exports = E; - -},{}]},{},[1])(1) -});
\ No newline at end of file diff --git a/node_modules/tiny-emitter/dist/tinyemitter.min.js b/node_modules/tiny-emitter/dist/tinyemitter.min.js deleted file mode 100644 index 74991365..00000000 --- a/node_modules/tiny-emitter/dist/tinyemitter.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var n;if(typeof window!=="undefined"){n=window}else if(typeof global!=="undefined"){n=global}else if(typeof self!=="undefined"){n=self}else{n=this}n.TinyEmitter=e()}})(function(){var e,n,t;return function r(e,n,t){function i(o,u){if(!n[o]){if(!e[o]){var s=typeof require=="function"&&require;if(!u&&s)return s(o,!0);if(f)return f(o,!0);var a=new Error("Cannot find module '"+o+"'");throw a.code="MODULE_NOT_FOUND",a}var l=n[o]={exports:{}};e[o][0].call(l.exports,function(n){var t=e[o][1][n];return i(t?t:n)},l,l.exports,r,e,n,t)}return n[o].exports}var f=typeof require=="function"&&require;for(var o=0;o<t.length;o++)i(t[o]);return i}({1:[function(e,n,t){function r(){}r.prototype={on:function(e,n,t){var r=this.e||(this.e={});(r[e]||(r[e]=[])).push({fn:n,ctx:t});return this},once:function(e,n,t){var r=this;function i(){r.off(e,i);n.apply(t,arguments)}i._=n;return this.on(e,i,t)},emit:function(e){var n=[].slice.call(arguments,1);var t=((this.e||(this.e={}))[e]||[]).slice();var r=0;var i=t.length;for(r;r<i;r++){t[r].fn.apply(t[r].ctx,n)}return this},off:function(e,n){var t=this.e||(this.e={});var r=t[e];var i=[];if(r&&n){for(var f=0,o=r.length;f<o;f++){if(r[f].fn!==n&&r[f].fn._!==n)i.push(r[f])}}i.length?t[e]=i:delete t[e];return this}};n.exports=r},{}]},{},[1])(1)});
\ No newline at end of file diff --git a/node_modules/tiny-emitter/index.d.ts b/node_modules/tiny-emitter/index.d.ts deleted file mode 100644 index b6574bbf..00000000 --- a/node_modules/tiny-emitter/index.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare class EventEmitter { - on (event: string, callback: Function, ctx?: any): EventEmitter; - once (event: string, callback: Function, ctx?: any): EventEmitter; - emit (event: string, ...args: any[]): EventEmitter; - off (event: string, callback?: Function): EventEmitter; -} - -export = EventEmitter diff --git a/node_modules/tiny-emitter/index.js b/node_modules/tiny-emitter/index.js deleted file mode 100644 index b85d8921..00000000 --- a/node_modules/tiny-emitter/index.js +++ /dev/null @@ -1,66 +0,0 @@ -function E () { - // Keep this empty so it's easier to inherit from - // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) -} - -E.prototype = { - on: function (name, callback, ctx) { - var e = this.e || (this.e = {}); - - (e[name] || (e[name] = [])).push({ - fn: callback, - ctx: ctx - }); - - return this; - }, - - once: function (name, callback, ctx) { - var self = this; - function listener () { - self.off(name, listener); - callback.apply(ctx, arguments); - }; - - listener._ = callback - return this.on(name, listener, ctx); - }, - - emit: function (name) { - var data = [].slice.call(arguments, 1); - var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); - var i = 0; - var len = evtArr.length; - - for (i; i < len; i++) { - evtArr[i].fn.apply(evtArr[i].ctx, data); - } - - return this; - }, - - off: function (name, callback) { - var e = this.e || (this.e = {}); - var evts = e[name]; - var liveEvents = []; - - if (evts && callback) { - for (var i = 0, len = evts.length; i < len; i++) { - if (evts[i].fn !== callback && evts[i].fn._ !== callback) - liveEvents.push(evts[i]); - } - } - - // Remove event from queue to prevent memory leak - // Suggested by https://github.com/lazd - // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 - - (liveEvents.length) - ? e[name] = liveEvents - : delete e[name]; - - return this; - } -}; - -module.exports = E; diff --git a/node_modules/tiny-emitter/instance.js b/node_modules/tiny-emitter/instance.js deleted file mode 100644 index 6dcdba21..00000000 --- a/node_modules/tiny-emitter/instance.js +++ /dev/null @@ -1,2 +0,0 @@ -var E = require('./index.js'); -module.exports = new E(); diff --git a/node_modules/tiny-emitter/package.json b/node_modules/tiny-emitter/package.json deleted file mode 100644 index 97dc9e79..00000000 --- a/node_modules/tiny-emitter/package.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "name": "tiny-emitter", - "version": "2.0.2", - "description": "A tiny (less than 1k) event emitter library", - "main": "index.js", - "scripts": { - "test-node": "tape test/index.js | tap-format-spec", - "test": "testling | tap-format-spec", - "bundle": "node_modules/.bin/browserify index.js > dist/tinyemitter.js -s TinyEmitter && echo 'Bundled'", - "minify": "node_modules/.bin/uglifyjs dist/tinyemitter.js -o dist/tinyemitter.min.js -m && echo 'Minified'", - "build": "npm test && npm run bundle && npm run minify", - "size": "node_modules/.bin/uglifyjs index.js -o minified.js -m && ls -l && rm minified.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/scottcorgan/tiny-emitter.git" - }, - "keywords": [ - "event", - "emitter", - "pubsub", - "tiny", - "events", - "bind" - ], - "author": "Scott Corgan", - "license": "MIT", - "bugs": { - "url": "https://github.com/scottcorgan/tiny-emitter/issues" - }, - "devDependencies": { - "@tap-format/spec": "0.2.0", - "browserify": "11.2.0", - "tape": "4.2.1", - "testling": "1.7.1", - "uglify-js": "2.5.0" - }, - "testling": { - "files": [ - "test/index.js" - ], - "browsers": [ - "iexplore/10.0", - "iexplore/9.0", - "firefox/16..latest", - "chrome/22..latest", - "safari/5.1..latest", - "ipad/6.0..latest", - "iphone/6.0..latest", - "android-browser/4.2..latest" - ] - } -} diff --git a/node_modules/tiny-emitter/test/index.js b/node_modules/tiny-emitter/test/index.js deleted file mode 100644 index 7f95f62f..00000000 --- a/node_modules/tiny-emitter/test/index.js +++ /dev/null @@ -1,217 +0,0 @@ -var Emitter = require('../index'); -var emitter = require('../instance'); -var test = require('tape'); - -test('subscribes to an event', function (t) { - var emitter = new Emitter(); - emitter.on('test', function () {}); - - t.equal(emitter.e.test.length, 1, 'subscribed to event'); - t.end(); -}); - -test('subscribes to an event with context', function (t) { - var emitter = new Emitter(); - var context = { - contextValue: true - }; - - emitter.on('test', function () { - t.ok(this.contextValue, 'is in context'); - t.end(); - }, context); - - emitter.emit('test'); -}); - -test('subscibes only once to an event', function (t) { - var emitter = new Emitter(); - - emitter.once('test', function () { - t.notOk(emitter.e.test, 'removed event from list'); - t.end(); - }); - - emitter.emit('test'); -}); - -test('keeps context when subscribed only once', function (t) { - var emitter = new Emitter(); - var context = { - contextValue: true - }; - - emitter.once('test', function () { - t.ok(this.contextValue, 'is in context'); - t.notOk(emitter.e.test, 'not subscribed anymore'); - t.end(); - }, context); - - emitter.emit('test'); -}); - -test('emits an event', function (t) { - var emitter = new Emitter(); - - emitter.on('test', function () { - t.ok(true, 'triggered event'); - t.end(); - }); - - emitter.emit('test'); -}); - -test('passes all arguments to event listener', function (t) { - var emitter = new Emitter(); - - emitter.on('test', function (arg1, arg2) { - t.equal(arg1, 'arg1', 'passed the first argument'); - t.equal(arg2, 'arg2', 'passed the second argument'); - t.end(); - }); - - emitter.emit('test', 'arg1', 'arg2'); -}); - -test('unsubscribes from all events with name', function (t) { - var emitter = new Emitter(); - emitter.on('test', function () { - t.fail('should not get called'); - }); - emitter.off('test'); - emitter.emit('test') - - process.nextTick(function () { - t.end(); - }); -}); - -test('unsubscribes single event with name and callback', function (t) { - var emitter = new Emitter(); - var fn = function () { - t.fail('should not get called'); - } - - emitter.on('test', fn); - emitter.off('test', fn); - emitter.emit('test') - - process.nextTick(function () { - t.end(); - }); -}); - -// Test added by https://github.com/lazd -// From PR: https://github.com/scottcorgan/tiny-emitter/pull/6 -test('unsubscribes single event with name and callback when subscribed twice', function (t) { - var emitter = new Emitter(); - var fn = function () { - t.fail('should not get called'); - }; - - emitter.on('test', fn); - emitter.on('test', fn); - - emitter.off('test', fn); - emitter.emit('test'); - - process.nextTick(function () { - t.notOk(emitter.e['test'], 'removes all events'); - t.end(); - }); -}); - -test('unsubscribes single event with name and callback when subscribed twice out of order', function (t) { - var emitter = new Emitter(); - var calls = 0; - var fn = function () { - t.fail('should not get called'); - }; - var fn2 = function () { - calls++; - }; - - emitter.on('test', fn); - emitter.on('test', fn2); - emitter.on('test', fn); - emitter.off('test', fn); - emitter.emit('test'); - - process.nextTick(function () { - t.equal(calls, 1, 'callback was called'); - t.end(); - }); -}); - -test('removes an event inside another event', function (t) { - var emitter = new Emitter(); - - emitter.on('test', function () { - t.equal(emitter.e.test.length, 1, 'event is still in list'); - - emitter.off('test'); - - t.notOk(emitter.e.test, 0, 'event is gone from list'); - t.end(); - }); - - emitter.emit('test'); -}); - -test('event is emitted even if unsubscribed in the event callback', function (t) { - var emitter = new Emitter(); - var calls = 0; - var fn = function () { - calls += 1; - emitter.off('test', fn); - }; - - emitter.on('test', fn); - - emitter.on('test', function () { - calls += 1; - }); - - emitter.on('test', function () { - calls += 1; - }); - - process.nextTick(function () { - t.equal(calls, 3, 'all callbacks were called'); - t.end(); - }); - - emitter.emit('test'); -}); - -test('calling off before any events added does nothing', function (t) { - var emitter = new Emitter(); - emitter.off('test', function () {}); - t.end(); -}); - -test('emitting event that has not been subscribed to yet', function (t) { - var emitter = new Emitter(); - - emitter.emit('some-event', 'some message'); - t.end(); -}); - -test('unsubscribes single event with name and callback which was subscribed once', function (t) { - var emitter = new Emitter(); - var fn = function () { - t.fail('event not unsubscribed'); - } - - emitter.once('test', fn); - emitter.off('test', fn); - emitter.emit('test'); - - t.end(); -}); - -test('exports an instance', function (t) { - t.ok(emitter, 'exports an instance') - t.ok(emitter instanceof Emitter, 'an instance of the Emitter class'); - t.end(); -}); |
