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
export function random(): number { | |
let random; | |
// https://zh.wikipedia.org/wiki/2147483647 | |
// 2147483647 === 1111111111111111111111111111111 | |
try { | |
const arr = new Uint32Array(1); | |
// https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues | |
window.crypto.getRandomValues(arr); | |
random = arr[0] & 2147483647; |
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
#![allow(dead_code)] | |
#![allow(unused_variables)] | |
#[macro_use] | |
extern crate log; | |
#[derive(Debug)] | |
enum Person { | |
// 一个 `enum` 可能是个 `unit-like`(类单元结构体), | |
Engineer, | |
Scientist, |
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
import Vue from 'vue'; | |
/** | |
* 代理字段到当前实例上 | |
* @eg: | |
* const src = {name: 'b'}; | |
* const target = {}; | |
* proxy(['name'], target, src); | |
* console.log(target.name); // => b | |
* target.name = 'a'; |
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
export default { | |
methods: { | |
/** | |
* find ancestor with specified component name. | |
* @param {string} name component name. | |
* @return {Vue} ancestor | |
*/ | |
findAncestor(name) { | |
var parent = this.$parent; | |
if (!parent) { |
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
(function(url){ | |
// 第一部分 | |
var dom,doc,where,iframe = document.createElement('iframe'); | |
iframe.src = "javascript:false"; | |
iframe.title = ""; iframe.role="presentation"; | |
(iframe.frameElement || iframe).style.cssText = "width: 0; height: 0; border: 0"; | |
where = document.getElementsByTagName('script'); | |
where = where[where.length - 1]; | |
where.parentNode.insertBefore(iframe, where); |
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
export default { | |
methods: { | |
/** | |
* find all sub components | |
* @param {string|function} name component name or validate function. | |
* @return {Array.<Vue>} result. | |
*/ | |
findComponents(name) { | |
const find = (result, child) => { | |
const isFound = typeof name === '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
function preg_quote( str ) { | |
// http://kevin.vanzonneveld.net | |
// + original by: booeyOH | |
// + improved by: Ates Goral (http://magnetiq.com) | |
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) | |
// + bugfixed by: Onno Marsman | |
// * example 1: preg_quote("$40"); | |
// * returns 1: '\$40' | |
// * example 2: preg_quote("*RRRING* Hello?"); | |
// * returns 2: '\*RRRING\* Hello\?' |
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
// copy from https://github.com/vuejs/vue/blob/v2.0.1/src/shared/util.js | |
/** | |
* Make a map and return a function for checking if a key | |
* is in that map. | |
*/ | |
export function makeMap ( | |
str: string, | |
expectsLowerCase?: boolean | |
): (key: string) => true | void { | |
const map = Object.create(null) |
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
(function() { | |
/** | |
* 记录方法使用情况的类 | |
* @param {Array.<boolean>} umMap 初始的使用情况 | |
*/ | |
var UsageManager = function(umMap) { | |
this.umMap = umMap || []; | |
}; | |
/** | |
* 记录新的使用情况 |
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
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] |
NewerOlder