npm config set registry https://registry.npm.taobao.org
或修改~/.npmrc文件(没有就自行新建一个),写入registry = https://registry.npm.taobao.org
配置后可通过下面方式来验证是否成功
npm config get registry
// toString(radix) | |
// 任意数值转为指定进制 | |
0x6600.toString(2) // "110011000000000" | |
// parseInt(value, radix) | |
// 将value作为指定进制radix来解析,得到10进制结果 | |
parseInt("110011000000000",2) // 26112 | |
// 任意进制相互转换 | |
// 先转10进制,再换成目标进制 |
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout)); |
public long DJBHash(String str) | |
{ | |
long hash = 5381; | |
for(int i = 0; i < str.length(); i++) | |
{ | |
hash = ((hash << 5) + hash) + str.charAt(i); | |
} | |
return hash; | |
} |
/** | |
A string hashing function based on Daniel J. Bernstein's popular 'times 33' hash algorithm. | |
@param {string} text - String to hash | |
@return {number} Resulting number. | |
*/ | |
function hash(text) { | |
'use strict'; | |
var hash = 5381, | |
index = text.length; |
n.copy = function(e, n, o) { | |
var c = d('<span class="my-gallery-src-copy-hidden">' + e + "</span>") | |
, s = d("body"); | |
s.append(c); | |
var a = document.createRange(); | |
a.selectNode(c.get(0)); | |
var i = window.getSelection(); | |
i.removeAllRanges(), | |
i.addRange(a); | |
var t = document.execCommand("copy"); |
// js 里 \x 开头的通常是16进制编码的数据,下面代码实现编解码: | |
// 解码 | |
//eg. | |
//decode('\x5f\x63\x68\x61\x6e\x67\x65\x49\x74\x65\x6d\x43\x72\x6f\x73\x73\x4c\x61\x79\x65\x72') | |
//"_changeItemCrossLayer" | |
function decode(str){ | |
return str.replace(/\\x(\w{2})/g,function(_,$1){ return String.fromCharCode(parseInt($1,16)) }); | |
} |
npm config set registry https://registry.npm.taobao.org
或修改~/.npmrc文件(没有就自行新建一个),写入registry = https://registry.npm.taobao.org
配置后可通过下面方式来验证是否成功
npm config get registry
function combine(arr, num) { | |
var r = []; | |
(function f(t, a, n) { | |
if (n == 0) return r.push(t); | |
for (var i = 0, l = a.length; i <= l - n; i++) { | |
f(t.concat(a[i]), a.slice(i + 1), n - 1); | |
} | |
})([], arr, num); | |
return r; | |
} |
// 适用于处理二维数组: ([['a','b'],['c'],['d']],2) --> [[["a","b"],["c"]],[["a","b"],["d"]],[["c"],["d"]]] | |
function dp_combine(a, m) { | |
var t = [[]], r = []; | |
for (var i = 0, n = a.length; i < n; ++i) { | |
for (var j = 0, l = t.length; j < l; ++j) { | |
(t[j].length < m - 1 ? t : r).push(t[j].concat([a[i]])); | |
} | |
} | |
return r; | |
} |
//es5 | |
function add(a, b) { | |
return a + b; | |
} | |
var curriedAdd = _.curry(add); | |
var add2 = curriedAdd(2); | |
add2(1);// 3 | |
//es6 |