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
// local, node database | |
import level from 'pouchdb-adapter-leveldb' | |
import Pouchy from 'pouchy' | |
Pouchy.plugin(level) | |
type Fruit = { | |
type: string, | |
tastes: string | |
} const fruit = new Pouchy<Fruit>({name : 'fruit'}) | |
const orange = await fruit.save({type : 'orange', tastes : 'delicious'}) |
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
var pouch = new PouchDB('mydb'); | |
var doc = {_id : 'mydoc', title : "Guess who?", text : "It's-a me, Mario!"}; | |
pouch.put(doc).then(function() { | |
return pouch.search({ | |
query : 'mario', | |
fields : [ 'title', 'text' ], | |
include_docs : true, | |
highlighting : true | |
}); |
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
export const clamp = (x: number, min: number, max: number): number => { | |
if (x < min) | |
return min; | |
if (x > max) | |
return max; | |
return x; | |
}; |
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
gulp.task('js', function () { | |
gulp.src('./js/*.js') | |
.pipe(uglify()) | |
.pipe(concat('all.js')) | |
.pipe(gulp.dest('./js')); | |
}); |
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
// 如果是 Safari 直接 return | |
if ( !(e.clipboardData && e.clipboardData.items) ) { | |
return; | |
} | |
// Mac平台下Chrome49版本以下 复制Finder中的文件的Bug Hack掉 | |
if(cbd.items && cbd.items.length === 2 && cbd.items[0].kind === "string" && cbd.items[1].kind === "file" && | |
cbd.types && cbd.types.length === 2 && cbd.types[0] === "text/plain" && cbd.types[1] === "Files" && | |
ua.match(/Macintosh/i) && Number(ua.match(/Chrome\/(\d{2})/i)[1]) < 49){ | |
return; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> |
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
import React from 'react'; | |
import { Platform} from 'react-native'; | |
import { MapView,Location, Permissions,Constants } from 'expo'; | |
export default class App extends React.Component { | |
state = { | |
location: null, | |
errorMessage: null, | |
}; |
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
import React, { Component } from 'react'; | |
import { Platform, Text, View, StyleSheet } from 'react-native'; | |
import { Constants, Location, Permissions } from 'expo'; | |
export default class App extends Component { | |
state = { | |
location: null, | |
errorMessage: null, | |
}; |
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
var reduce = fn => (Arr, acc) => Arr.reduce(fn, acc); | |
var add = reduce((acc,x)=>acc+x); | |
add([1,2,3],0);// -> 6 |
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
// Async compose | |
const compose = (…functions) => input => functions.reduceRight((chain, func) => chain.then(func), Promise.resolve(input)); | |
// Functions fn1, fn2, fn3 can be standard synchronous functions or return a Promise | |
compose(fn3, fn2, fn1)(input).then(result => console.log(`Do with the ${result} as you please`)) |
NewerOlder