1.1.2 • Published 5 years ago

permeator-core v1.1.2

Weekly downloads
5
License
ISC
Repository
github
Last release
5 years ago

PermeatorCore

用于封装 API 使得各平台使用方式一致.image.png查看快速入门文档 | github | API 参考

安装

npm i permeator-core -S

使用

import PermeatorCore from 'permeator-core'

const p = new PermeatorCore('aName')

p.$use({
  name: 'aPlatform',
  envTest: () => env === 'aPlatform',
  permeator: {
    doSomeThing: () => 'show A'
  }
});

p.$use({
  name: 'bPlatform',
  envTest: () => env === 'bPlatform',
  permeator: {
    doSomeThing: () => 'show B'
  }
});

然后你将得到

// 如果 env === 'aPlatform'
p.ready(() => {
  p.doSomeThing() // show A
});

// 如果 env === 'bPlatform'
p.ready(() => {
  p.doSomeThing() // show B
});

以及下面更实用的方法

p.inAPlatform(() => {
  // 如果 env === 'aPlatform' 这里将执行, 而另外一个则不执行
});

p.inBPlatform(() => {
  // 如果 env === 'bPlatform' 这里将执行, 而另外一个则不执行
});

更多 API 参考

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago