tools
code:script.js
export const sleep = (milliseconds) => new Promise(resolve => setTimeout(resolve, milliseconds));
追加メソッド
range
code:script.js
Array.range = function(n) {
return Array.from(Array(n), (v, k) => k);
}
前後の空白をそのままに行ごとにmapする
code:script.js
String.prototype.mapLine = function(func) {
}
サンドイッチする
code:script.js
String.prototype.sandwich = function(left,right) {
return (this. replace(/(.+)/g, left+"$1"+right));
}
数式用のエスケープ
code:script.js
String.prototype.mathEsc = function() {
return (this.replace(/\s/g,"\\ "). replace(/\^/,"\^\\wedge"));
}
数式モード
code:script.js
String.prototype.mathMode = function() {
return (this.sandwich("\$ "," ")); }