This file contains 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 curry(fn) { | |
// fn(1,2,3) => fn(1)(2,3) => fn(1,2)(3) | |
// so it return a function which: | |
// 1. if enough param, just run it | |
// 2. if not enough param, return another function with param prefilled | |
return function curried(...args) { | |
if (args.length >= fn.length) { | |
return fn.apply(null, args) | |
} else { | |
return curried.bind(null, ...args) |
This file contains 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
const myNew = (constructor, ...args) => { | |
// 1. create an object based on constructor.prototype | |
const obj = Object.create(constructor.prototype) | |
// 2. run constructor with this set to the above object | |
const result = constructor.call(obj, ...args) | |
// 3. if return value is object, user that. if not use the newly created one | |
if (result instanceof Object) { | |
return result | |
} |
This file contains 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.prototype.mycall = function(target, ...args) { | |
const key = Symbol() | |
target[key] = this | |
const result = target[key](...args) | |
delete target[key] | |
return result | |
} |
This file contains 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
const debounce = (func, wait, options = { | |
leading: false, | |
trailing: true | |
}) => { | |
// same timer for leading and trailing | |
let timer = null | |
// special flag to skip the trailing call if leading is true | |
let isCalledForLeading = false |
This file contains 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
const app = express(); | |
app.use(router); | |
const configPC = require('../pc/nuxt.config.js'); | |
const configSP = require('../sp/nuxt.config.js'); | |
const nuxtPC = new Nuxt(configPC); | |
const nuxtSP = new Nuxt(configSP); | |
// Enable live build & reloading on dev | |
if (nuxtPC.options.dev) { |
This file contains 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
{ | |
"index.js": { | |
"_source": { | |
"children": [ | |
{ | |
"children": [ | |
"/******/ (function(modules) { // webpackBootstrap\n", | |
{ | |
"_source": { | |
"_value": " \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// exp |
This file contains 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
/*1482118385,,JIT Construction: v2746767,en_US*/ | |
/** | |
* Copyright Facebook Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
*/ | |
try { | |
(function(win, doc, location, history) { | |
'use strict'; |