This file contains hidden or 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
This file contains hidden or 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
const path = require('path') | |
const { src, dest, parallel, watch, series } = require('gulp') | |
const ts = require('gulp-typescript') | |
const clean = require('gulp-clean') | |
const program = require('commander') | |
// enum of mode | |
const MODE = { | |
PRODUCTION: 'production', | |
DEVELOPMENT: 'development' |
This file contains hidden or 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
// 有 Bug 如果绑定元素有子元素那么点击子元素无法触发 | |
// function listen (element, eventType, selector, fn) { | |
// element.addEventListener(eventType, event => { | |
// let { target } = event | |
// if (target.matches(selector)) { | |
// fn.call(target, event, target) | |
// } | |
// }) | |
// } |
This file contains hidden or 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
class EventEmitter { | |
constructor () { | |
this.events = {} | |
} | |
on (eventName, callback) { | |
const callbacks = this.events[eventName] || [] | |
callbacks.push(callback) | |
this.events[eventName] = callbacks | |
} |
This file contains hidden or 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
function debounce (fn, duration = 1000) { | |
let timer = null | |
return function (...args) { | |
if (timer) clearTimeout(timer) | |
timer = setTimeout(() => { | |
fn(...args) | |
}, duration) | |
} | |
} |
This file contains hidden or 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
Object.create = function (proto) { | |
function F () {} | |
F.prototype = proto | |
return new F() | |
} | |
function mockNew (constructor, ...args) { | |
const isPrimitive = result => { | |
if (result instanceof Object === true) { | |
return true |
This file contains hidden or 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
function APromise(fn) { | |
const handlers = []; | |
let state = "pending"; | |
let value = null; | |
this.then = function(onResolved, onRejected) { | |
return new APromise((resolve, reject) => { | |
handle({ | |
onResolved, | |
resolve, |
This file contains hidden or 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
const gulp = require('gulp') | |
const rename = require('gulp-rename') | |
const del = require('del') | |
const through = require('through2') | |
const colors = require('ansi-colors') | |
const log = require('fancy-log') | |
const argv = require('minimist')(process.argv.slice(2)) |