提交 6b7ebf71 authored 作者: DengYun's avatar DengYun

first commit

上级
{
"extends": "eslint-config-airbnb",
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"mocha": true
},
"rules": {
// Disable for console/alert
"no-console": 0,
"no-alert": 0,
"indent": [2, 2, {"SwitchCase": 1}]
},
"plugins": [
"react", "import"
],
"settings": {
"import/parser": "babel-eslint",
"import/resolve": {
"moduleDirectory": ["node_modules", "src"]
}
},
"globals": {
"__DEV__": true
}
}
\ No newline at end of file
/node_modules
/.idea
language: node_js
/**
* Created by tdzl2_000 on 2015-12-29.
*/
import { NativeModules } from 'react-native';
import promisify from 'es6-promisify';
const native = NativeModules.HttpCache;
// Used only with promisify. Transform callback to promise result.
function translateError(err, result) {
if (!err) {
return this.resolve(result);
}
if (typeof err === 'object') {
if (err instanceof Error) {
return this.reject(ret);
}
const {message, ...other} = err;
return this.reject(Object.assign(new Error(err.message), other));
} else if (typeof err === 'string') {
return this.reject(new Error(err));
}
this.reject(Object.assign(new Error(), { origin: err }));
}
function wrapApi(nativeFunc, argCount) {
if (!nativeFunc) {
return undefined;
}
const promisified = promisify(nativeFunc, translateError);
if (argCount){
return (...args) => {
args[argCount-1] = args[argCount-1] || undefined;
return promisified(...args);
};
} else {
return () => {
return promisified();
};
}
}
export const clearCache = wrapApi(native.clearCache);
export const getSize = wrapApi(native.getSize);
{
"name": "react-native-http-cache",
"version": "0.1.0",
"description": "Control http cache used by fetch/XMLHttpRequest",
"main": "index.js",
"scripts": {
"test": "node node_modules/eslint/bin/eslint ."
},
"repository": {
"type": "git",
"url": "git+https://github.com/reactnativecn/react-native-http-cache.git"
},
"keywords": [
"react-native",
"ios",
"android",
"http",
"cache"
],
"author": "tdzl2003",
"license": "ISC",
"bugs": {
"url": "https://github.com/reactnativecn/react-native-http-cache/issues"
},
"homepage": "https://github.com/reactnativecn/react-native-http-cache#readme",
"devDependencies": {
"babel-eslint": "^4.1.6",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^2.1.1",
"eslint-plugin-import": "^0.12.1",
"eslint-plugin-react": "^3.13.1"
},
"dependencies": {
"es6-promisify": "^3.0.0"
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论