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
| type IsFunc = { | |
| value: boolean; | |
| (getNew: boolean): boolean; | |
| }; | |
| // More details: | |
| // @see: https://melvingeorge.me/blog/add-properties-to-functions-typescript | |
| export const isDevEnv = <IsFunc>((getNew: boolean) => { | |
| if (isDevEnv.value && !getNew) { | |
| return isDevEnv.value; |
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 pipe = (...fns) => (value) => reduce(fns, (acc, fn) => fn(acc), value) |
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 reduce = (array, fn, initialValue) => { | |
| let accumlator | |
| if (initialValue != undefined) { | |
| accumlator = initialValue | |
| } else { | |
| accumlator = array[0] | |
| } | |
| if (initialValue === undefined) { | |
| for (let i = 1; i < array.length; i++) { | |
| accumlator = fn(accumlator, array[i]) |
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
| /** | |
| * 生成随机数数组(用于算法练习) | |
| * @param {number} digits 生成多少位数字 | |
| * @param {number} length 数组长度 | |
| * @return {array} 包含需求的随机数组成数组 | |
| */ | |
| function generateRandomNumberArray(digits = 3, length = 1000) { | |
| if (typeof digits !== 'number' || typeof length !== 'number') { | |
| throw new Error('Digits and length must be number type') | |
| } |
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
| { | |
| "arrowParens": "always", | |
| "bracketSpacing": true, | |
| "cursorOffset": -1, | |
| "endOfLine": "auto", | |
| "htmlWhitespaceSensitivity": "css", | |
| "jsxSingleQuote": true, | |
| "printWidth": 80, | |
| "semi": false, | |
| "singleQuote": 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>React Playground</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react-dom.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script> |
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
| import Listener from './listeners.js' | |
| const getModal = () => import('./src/modal.js') | |
| Listener.on('didSomethingToWarrentModalBeingLoaded', () => { | |
| // Async fetching modal code from a separate chunk | |
| getModal().then((module) => { | |
| const modalTarget = document.getElementById('Modal') | |
| module.initModal(modalTarget) | |
| }) |
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
| // jQuery Callbacks & Deferred & when function | |
| // ==== Callbacks ==== | |
| var flagsCache = {} | |
| function createFlags(flags) { | |
| var object = flagsCache[flags] = {}, | |
| i, | |
| length |
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 downloadData(data, filename, type) { | |
| var file = new Blob(["\ufeff" + data], { type: type }); | |
| if (window.navigator.msSaveOrOpenBlob) | |
| // IE10+ | |
| window.navigator.msSaveOrOpenBlob(file, filename); | |
| else { | |
| // Others | |
| var a = document.createElement("a"), | |
| url = URL.createObjectURL(file); | |
| a.href = url; |
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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>立方体</title> | |
| <style> | |
| /*为什么两层div包裹各面后,旋转时不会出现畸变?*/ | |
| .magic{ | |
| position: absolute;/*子元素的绝对定位首先寻找已定位的父元素作参照。*/ | |
| top: 50%;/*只有absolute才有top和left等值。 */ |