promise-operators

1.0.0 • Public • Published

Promise 回调函数操作

import {judge, pickUp} from '@jt/promise-operators';
import _ from 'lodash';

async function test() {
  try {
    const result = await new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve({
          code: 0,
          result: {
            list: []
          }
        })
      }, 1000);
    })
    .then(judge(_.isObject))
    .then(pickUp(res=>res.result));
  } catch(error) {
    console.log('请求接口错误');
  }
}

/promise-operators/

    Package Sidebar

    Install

    npm i promise-operators

    Weekly Downloads

    0

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    1.76 kB

    Total Files

    5

    Last publish

    Collaborators

    • wulunyi