Skip to content

Instantly share code, notes, and snippets.

function addComments(arg, name) {
// 当参数前的注释不存在的情况, 加入 webpackChunkName 注释
if (!arg.leadingComments) {
arg.leadingComments = [
{
type: 'CommentBlock',
value: ` webpackChunkName: '${name}' `,
},
]
}
@hjzheng
hjzheng / web.md
Last active July 10, 2019 06:38
评估web架构的关键属性

HTTP 协议应当在以下属性中取得可接受的均衡

  1. 性能 Performance 影响高可用的关键性
  2. 可伸缩性 Scalability 支持部署可以相互交互的大量组件
  3. 简单性 Simplicity 易理解,易实现,易验证
  4. 可见性 Visiable 对两个组件的交互进行监视或仲裁能力 如缓存,分层设计等
  5. 可移植性 Portability 在不同环境下的运行能力
  6. 可靠性 Reliability 出现问题时,对整体影响程度
  7. 可修改性 Modifiability 对系统做出修改的难易程度,由可进化性,可定制性,可扩展性,可配置性,可重用性构成
@hjzheng
hjzheng / ys.md
Created May 7, 2019 12:13
知识总结
  1. npm 本地依赖
"dependencies": {
    "@ys/components": "file:./components",
    "@ys/domain": "file:./domain",
  1. qs 库处理 queryString 非常强大

https://www.npmjs.com/package/qs

@hjzheng
hjzheng / redux_practice.js
Created April 23, 2019 10:29
redux createStore and combineReducer
/*
* Open the console
* to see the state log.
*/
const todo = (state, action) => {
if (action.type === 'ADD_TODO') {
return {
id: action.id,
text: action.text,
@hjzheng
hjzheng / looksLike.js
Created February 1, 2019 09:08
looksLike
const disallowedMethods = ['log', 'info', 'warn', 'error', 'dir']
module.exports = {
create(context) {
return {
Identifier(node) {
if (
!looksLike(node, {
name: 'console',
parent: {
@hjzheng
hjzheng / auto-switch-node-version.sh
Last active December 5, 2018 09:21
auto-switch-node-version.sh
#!/bin/bash
# usage: auto-switch-node-version.sh v8.11.1 'npm install&&npm run build:qa'
# you can also use nvm run 8.11.1 app.js or nvm exec 8.11.1 node app.js
newNodeVersion=$1
oldNodeVersion=`node -v`
source ~/.nvm/nvm.sh
@hjzheng
hjzheng / DOM-vs-YUI2.txt
Created December 13, 2017 05:40
DOM 操作与 YUI2 Dom的实现对比
1.Javascript中的String是没有trim方法,为String加上trim方法
//自定义函数
if (!String.trim) {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,'');
}
}
//YUI
2.YAHOO.lang.trim(s)
参数 字符串 , 返回值 字符串
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>使用代理合并 http 请求</title>
</head>
<body>
<input type="checkbox" id="1"/>
<input type="checkbox" id="2"/>
@hjzheng
hjzheng / PromiseSimpleExample.js
Created October 14, 2017 16:38 — forked from treyhuffine/PromiseSimpleExample.js
An example using a simple promise implementation
class PromiseSimple {
constructor(executionFunction) {
this.promiseChain = [];
this.handleError = () => {};
this.onResolve = this.onResolve.bind(this);
this.onReject = this.onReject.bind(this);
executionFunction(this.onResolve, this.onReject);
}
@hjzheng
hjzheng / Excel-Number-Format.md
Created August 28, 2017 09:55
前端导出 Excel 表格,数字格式,通过样式进行处理
.num {
  mso-number-format:General;
}
.text{
  mso-number-format:"\@";/*force text*/
}