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
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | |
# yarn lockfile v1 | |
"@babel/[email protected]", "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.0.0-beta.35": | |
version "7.0.0" | |
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8" | |
integrity sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA== | |
dependencies: | |
"@babel/highlight" "^7.0.0" |
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
import * as React from "react"; | |
import { isValidElement } from "react"; | |
import { createStyle } from "@xialvjun/create-react-style"; | |
const StyleContext = createStyle(); | |
function format_style(style) { | |
if (!style) { | |
return ""; | |
} |
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
import { createContext } from '@xialvjun/create-react-context'; | |
import { create_client } from '@xialvjun/tiny-graphql-client'; | |
import React, { Component } from 'react'; | |
const tiny_client = create_client(async (body, extra_headers) => { | |
const res = await fetch('http://127.0.0.1:3000/graphql', { | |
method: 'post', | |
body: JSON.stringify(body), | |
headers: { |
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
import React, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
var data = [ | |
['1','1.1','1.1.1'], | |
['1','1.1','1.1.2'], | |
['1','1.1','1.1.3'], | |
['1','1.2','1.2.1'], | |
['1','1.2','1.2.2'], | |
['2','2.1','2.1.1', '2.1.1.1'], |
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
// https://github.com/lodash/lodash/issues/1696 | |
import {clone, setWith, curry} from 'lodash/fp'; | |
// export const setIn = curry((path, value, obj) => | |
// setWith(clone, path, value, clone(obj)), | |
// ); | |
export const setIn = curry((obj, path, value) => | |
setWith(clone, path, value, clone(obj)), | |
); |
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
import React from 'react'; | |
import { render } from 'react-dom'; | |
import { BrowserRouter, Switch, Route, Link, withRouter, matchPath } from 'react-router-dom'; | |
const db = { | |
authors: [ | |
{ id: '8', name: 'xialvjun', gender: 'M', }, | |
{ id: '1', name: 'lilei', gender: 'M' }, | |
{ id: '7', name: 'hanmeimei', gender: 'F' }, |
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
// 返回一个可以任意执行,但内部并发只有 count 的函数 | |
function limit(fn, count) { | |
let n = 0; | |
let ps = []; | |
function work(...args) { | |
n++; | |
let rp = fn(...args); | |
rp.then(_ => { | |
n--; | |
let next = ps.shift();// ps[0]; |
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
// 其实这并不 safe。。。因为 js 中所有的数字其实都是浮点数,哪怕整数也是浮点数。。。 | |
// 数值比较小的整数可能看不出来浮点数的特性,但是当数值比较大时,就能看出来了 | |
// 还是直接用库来的方便实在:https://github.com/defunctzombie/num | |
function safe_add(a, b) { | |
const decimal_length = Math.max(...[a, b].map(n => (n + '').split('.')).map(n => (n[1] || '').length)); | |
const power = Math.pow(10, decimal_length); | |
// 不要把 a*power+b*power 变为 (a+b)*power | |
return Math.round(a * power + b * power) / power; | |
} |
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
const DataLoader = require('dataloader'); | |
const { knex } = require('./singleton.js'); | |
function middleware(ctx, next) { | |
const target = {}; | |
const handler = { | |
get: function (receiver, table_name$key_column_name$) { | |
if (receiver[table_name$key_column_name$]) { | |
return receiver[table_name$key_column_name$]; |
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 some_sync(...ps) { | |
return (async () => { | |
let errors = [] | |
while (true) { | |
try { | |
return await ps[errors.length] | |
} catch (error) { | |
errors.push(error) | |
if (errors.length === ps.length) { | |
throw errors |
NewerOlder