1.1.16 • Published 5 years ago

cleverpromise v1.1.16

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

cleverPromise

npm.io

npm.io

Classes

  • pathWrapper :封装处理路径方法

  • utilWrapper :封装常用的JS技巧

  • DateWrapper :封装时间操作辅助方法

Modules

  • arrayWrapper :同步化异步编程,数组化处理 promise
  • objectWrapper :同步化异步编程,对象化处理 promise

API Documentation:

documentation

示例:

导入方式 :

let {arrayWrapper,objectWrapper} = require('cleverpromise')

案例 1:(promise wrapper)

async function f() {
  var [p1Error, p1Result] = await arrayWrapper(promise1)
  console.log(p1Error, p1Result)
}

案例 2: (file)

const {pathWrapper} = require('cleverpromise')
const fullPath = '/usr/local/bin/test.js'
const currentFileName = pathWrapper.getFileName(fullPath,'.js')

案例 3 (util )

// uniqe 
const {utilWrapper} = require('cleverpromise')


 const u = utilWrapper.uniqueArray(arr)

// rapidLoop

const fn = item => {
        const a = item ** 2;
        console.log(a)
        return a
      };

      utilWrapper.rapidForLoop([1, 23, 4,,23,2,3,23,12,312,3,21,3,21,3,12321], fn)
      
// quickrounding
   const num1 = 24.5
   const num2 = -24.3
   const num3 = 2323.123245784565
   console.log(utilWrapper.quickRounding(num1))
   console.log(utilWrapper.quickRounding(num2))
   console.log(utilWrapper.quickRounding(num3))
 
// safeNumber

 const exp1 = 0.1 + 0.2
 
 console.log(utilWrapper.safeNumber(exp1), typeof utilWrapper.safeNumber(exp1))
 
 const exp2 = 0.756*0.22
 
 console.log(utilWrapper.safeNumber(exp2,20), typeof utilWrapper.safeNumber(exp2))

案例4 (date )

const {DateWrapper} = require('cleverpromise')
const  date1 = '2018-12-2 11:22'
const  date2 = '2018/12/2 11:22'
console.log(DateWrapper.transDateStringStandard(date1))
console.log(DateWrapper.transDateStringStandard(date2))
1.1.16

5 years ago

1.1.15

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago