Skip to content

Instantly share code, notes, and snippets.

@Yang03
Yang03 / 1.scss
Last active January 19, 2018 09:53
<div class="ellips">
<div class="dot"></div>
</div>
$pi: 3.14159265359;
$_precision: 10;
@function pow($base, $exp) {
$pi: 3.14159265359;
$_precision: 10;
@function pow($base, $exp) {
$value: $base;
@if $exp > 1 {
@for $i from 2 through $exp {
$value: $value * $base;
}
}
@Yang03
Yang03 / redux.js
Created January 5, 2018 09:52
redux.js
const log = (store) => (next) => (action) {
console.log('start')
next(action)
console.log('end')
}
function applayMiddleware (...middlewares) {
return (createStore) {
return (reducer, preloadedState,enhancer){
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
#marquee {
height:120px;
overflow:hidden;
function fnWrapDecorator(fn) {
return (...args) => {
return (target, propertyKey, descriptor) => {
const fn = descriptor.value
let wrappedFn = fn.applay(null, [fn, ...args])
return {
configurable: true,
get() {
return fn
@Yang03
Yang03 / Object.defineProperty
Last active October 10, 2017 07:35
Object.defineProperty
var foo = {}
Object.defineProperty(foo, 'name', {
configurable: true, //是否可以delete foo.delete
enumerable: true, // 是否for in可以返回属性
writable:true, //是否可以重新赋值
value: 'kobe'
})
var descriptor = Object.getOwnPropertyDescriptor(foo, 'name')
console.log(descriptor.value)
Element
document
window
XMLHttpRequest
...
onchange={(e:FormEvent<HTMLInputElement>) => {
event.currentTarget
const v = e.target.value // property 'value' does not exit on type 'EventTarget'
.listing-item__title
.listing-item__item--active
// - 两个单词的链接
//__ element
// -- midifier
@Yang03
Yang03 / JSON.stringify
Created July 28, 2017 03:34
JSON.stringify() function
var obj = {a: 1, b:2}
console.log(JSON.stringify(obj)) // {"a":1,"b":1}
var obj1 = {
a:1,
b: function() {
console.log(1)
},
c: undefined
}
@Yang03
Yang03 / sinon
Created July 25, 2017 10:34
sinon.js 测试
sinon spies, stubs(stəb,存根), mocks
spies sinon.spy() //会调用原来的function
stubs //完全代替之前的function,不会执行原来的function
mocks //和stubs一样,可以用来替换整个对象以改变其行为