ppi,每英寸像素数量。
根据像素和屏幕尺寸计算 ppi。
/*
// saved at root of repo, or global | |
registry = https://registry.npm.taobao.org | |
sass_binary_site = https://npm.taobao.org/mirrors/node-sass/ | |
electron_mirror = https://npm.taobao.org/mirrors/electron/ |
function download(text: string, name: string, type: string) { | |
var a = document.createElement('a') | |
a.style.display = "block"; | |
var file = new Blob([text], {type: type}); | |
a.href = URL.createObjectURL(file); | |
a.download = name; | |
document.body.appendChild(a); | |
a.click(); | |
document.body.removeChild(a); | |
} |
function repeatChar(char, times) { | |
if (typeof String.prototype.repeat === 'function') { | |
return char.repeat(times) | |
} | |
let count = 0 | |
const array = [] | |
while (count < times) { | |
count += 1 | |
array.push(char) | |
} |
const debounce = (func, delay) => { | |
let inDebounce | |
return function() { | |
const context = this | |
const args = arguments | |
clearTimeout(inDebounce) | |
inDebounce = setTimeout(() => func.apply(context, args), delay) | |
} | |
} |
/* | |
* | |
* Demo: https://repl.it/@wangpin34/array-utils | |
*/ | |
/* | |
* Filter elements which pass the test function | |
*/ | |
func filter(in interface{}, testFunc func(interface{}) bool) *[]interface{} { | |
b, _ := json.Marshal(in) |
const dotenv = require('dotenv') | |
const path = require('path') | |
const fs = require('fs') | |
function load() { | |
if (process.env.stack) { | |
return dotenv.config({ path: path.join(__dirname, `.env.${process.env.stack}`) }) | |
} | |
return dotenv.config() | |
} |
.env.dev | |
.env.qa | |
.env.stg | |
.env.prod |
function handleKeydown(e) { | |
if (e.shiftKey) { | |
if (e.which !== 9) { | |
e.preventDefault() | |
} | |
} | |
if (e.which > 57) { | |
e.preventDefault() | |
} | |
if (e.which === 32) { |
app.js
import React, { Component } from 'react';
import './app.scss';
const Bracket = ({b}) => <span className="bracket"> {b} </span>;
const ListWrapper = ({children}) => <section>{children}</section>;
const MapWrapper = ({children}) => <section>{children}</section>;
const NodeKey = ({k}) => (<label>{'"' + k + '"'}:</label>);