websdk-test
TypeScript icon, indicating that this package has built-in type declarations

0.0.12 • Public • Published

efox-websdk

概述

efox-websdk统一调用sdk工具

安装

npm install @efox/efox-websdk

引入

import WebSDk from 'websdk-test'
const local = {}

if (window.YY) {
  local.sdk = require('./cef').default
  local.env = 'isCef'
} else {
  local.sdk = require('./web').default
  local.env = 'web'
}
const sdk = new WebSDk(local.sdk, local.env)

const method = sdk.get
export {
  method as default,
  sdk
}
export const WebSDKPlugin = {
  install (Vue) {
    Vue.prototype.$WebSDK = method
  }
}

使用

WebSDK('sayHello', id, { name: 'input Name' }).then(res => {}); // => sayHello(id, object)  
WebSDK('os.versions[0].date.catch').then(res => {}).catch(err => {}); // => { os = { versions: [{  }]} }; process catch method  

api 错误码

{
  code: 1,
  error: 'key not found',
  env: local.env,
  key: keyName
}

其它关于jest ts

配置ts jest

  • 1 npm install --save-dev jest ts-jest @types/jest
  • 2 Modify your project's package.json
"jest": {
  "transform": {
    "^.+\\.tsx?$": "ts-jest"
  },
  "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
  "moduleFileExtensions": [
    "ts",
    "tsx",
    "js",
    "jsx",
    "json",
    "node"
  ]
}

jest ts: https://github.com/kulshekhar/ts-jest

test用例

/root/__test__
文件名: xxx.test.ts
执行: npm run test -> jest --verbose --colors --bail

发布

npm adduser 输入账号密码
更新package.json的版本
npm publish

Readme

Keywords

Package Sidebar

Install

npm i websdk-test

Weekly Downloads

0

Version

0.0.12

License

ISC

Unpacked Size

12.9 kB

Total Files

13

Last publish

Collaborators

  • yangshangzhi