This file contains hidden or 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
// 一个需要curry的种子函数 | |
const addSeed = (a, b) => a + b; | |
// 这种方式 必须明确f的参数是确定的 | |
function curry(f) { | |
// 主要是把curried之后的参数不断累起来,直到参数个数达到f的参数个数后,直接调用f | |
return function curried(...args) { | |
// f.length是参数的个数 | |
if (args.length >= f.length) { | |
return f(...args) |
This file contains hidden or 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
'use strict'; | |
function counter(state, action) { | |
switch (action.type) { | |
case 'INCREMENT': | |
return state + 1; | |
case 'DECREMENT': | |
return state - 1; | |
default: | |
return state; |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>object assign</title> | |
</head> | |
<body> | |
<script id="jsbin-source-javascript" type="text/javascript"> | |
var objectAssign = function(target, source) { |
This file contains hidden or 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
.border1px{ | |
position: relative; | |
} | |
.border1px::after{ | |
content: " "; | |
width: 200%; | |
height: 200%; | |
position: absolute; | |
border: 1px solid #FFFFFF; | |
transform-origin: top left; |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/> | |
<meta name="apple-touch-fullscreen" content="yes"> | |
<meta name="format-detection" content="telephone=no,email=no"> | |
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"> | |
<style type="text/css"> | |
input[type="checkbox"]{ |
This file contains hidden or 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 (win, option) { | |
var count = 0, | |
designWidth = option.designWidth, | |
designHeight = option.designHeight || 0, | |
designFontSize = option.designFontSize || 20, | |
callback = option.callback || null, | |
root = document.documentElement, | |
body = document.body, | |
rootWidth, newSize, t, self; |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>跑马灯</title> | |
<style type="text/css"> | |
.listdroll-wrap{ | |
width: 80%; | |
margin: 100px auto; | |
background-color: rgba(0,0,0,0.5); |
This file contains hidden or 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
/** | |
* 处理字节大小显示不同单位类型的描述 | |
* @param imgTotalSize | |
* @returns {*} | |
*/ | |
export const showImgSize = (imgTotalSize) => { | |
if (imgTotalSize === 0) return '0M'; | |
const allSizeM = (imgTotalSize / 1024 / 1024).toFixed(2); | |
const allSizeKB = (imgTotalSize / 1024).toFixed(2); | |
if (allSizeKB < 0.01) { |
This file contains hidden or 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
/** | |
* 从数组中移除某一项 | |
* @param arr | |
* @param item | |
*/ | |
export const removeItemFromArr = (arr, item) => { | |
const index = arr.indexOf(item); | |
const newArr = arr.slice(); | |
newArr.splice(index, 1); | |
return newArr; |
This file contains hidden or 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
/** | |
* 对于较小的图片 可以直接读取 做预览 | |
* @param img | |
* @returns {Promise} | |
*/ | |
export const getBase64 = (img) => { | |
return new Promise((resolve, reject) => { | |
const reader = new FileReader(); | |
reader.addEventListener('load', () => { | |
const src = reader.result; |