Skip to content

Instantly share code, notes, and snippets.

View xudaolong's full-sized avatar
🎯
Focusing

Dillon Xu xudaolong

🎯
Focusing
View GitHub Profile
@xudaolong
xudaolong / Trie.js
Created May 27, 2019 02:30 — forked from deadlocked247/Trie.js
Trie implementation in ES6, good for string autocomplete
/* Class representing a Trie data structure */
export default class Trie {
/**
* Creates a Trie
* @return {Object} Trie
*/
constructor() {
this.words = 0;
this.prefixes = 0;
@xudaolong
xudaolong / actions.js
Last active May 13, 2020 09:08 — forked from AlexFrazer/actions.js
Redux - Action Component Rendux 集合|-|{"files":{"component.jsx":{"env":"plain","abbr":"jjj"},"actions.js":{"env":"plain","abbr":""}},"tag":"Uncategorized"}
import fetch from 'isomorphic-fetch';
export const REQUEST_POSTS = 'posts/REQUEST';
export const RECEIVE_POSTS = 'posts/RECEIVE';
export const ERROR_POSTS = 'posts/ERROR';
export const ADD_FILTER = 'posts/ADD_FILTER';
export const REMOVE_FILTER = 'posts/REMOVE_FILTER';
// this action is a generic get all posts
@xudaolong
xudaolong / fetcherUtil.js&env=js&abbr=`aaa&label=aaa
Last active May 6, 2019 02:18 — forked from LopatkinEvgeniy/fetcher.js
JavaScript-Fetch 优雅使用|-|&tag=Other
import fetch from 'isomorphic-fetch';
// usage : const { status, data, error } = yield fetcher('/api/url');
export default function fetcher(url, options = {}) {
return new Promise((resolve) => {
fetch(url, Object.assign({}, {
credentials: 'same-origin',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',