معرفی شرکت ها


universalify-2.0.0


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

Make a callback- or promise-based function support both promises and callbacks.
ویژگی مقدار
سیستم عامل -
نام فایل universalify-2.0.0
نام universalify
نسخه کتابخانه 2.0.0
نگهدارنده ['ryanzim']
ایمیل نگهدارنده ['opensrc@ryanzim.com']
نویسنده Ryan Zimmerman
ایمیل نویسنده opensrc@ryanzim.com
آدرس صفحه اصلی git+https://github.com/RyanZim/universalify.git
آدرس اینترنتی https://github.com/RyanZim/universalify#readme
مجوز MIT
# universalify [![Travis branch](https://img.shields.io/travis/RyanZim/universalify/master.svg)](https://travis-ci.org/RyanZim/universalify) ![Coveralls github branch](https://img.shields.io/coveralls/github/RyanZim/universalify/master.svg) ![npm](https://img.shields.io/npm/dm/universalify.svg) ![npm](https://img.shields.io/npm/l/universalify.svg) Make a callback- or promise-based function support both promises and callbacks. Uses the native promise implementation. ## Installation ```bash npm install universalify ``` ## API ### `universalify.fromCallback(fn)` Takes a callback-based function to universalify, and returns the universalified function. Function must take a callback as the last parameter that will be called with the signature `(error, result)`. `universalify` does not support calling the callback with three or more arguments, and does not ensure that the callback is only called once. ```js function callbackFn (n, cb) { setTimeout(() => cb(null, n), 15) } const fn = universalify.fromCallback(callbackFn) // Works with Promises: fn('Hello World!') .then(result => console.log(result)) // -> Hello World! .catch(error => console.error(error)) // Works with Callbacks: fn('Hi!', (error, result) => { if (error) return console.error(error) console.log(result) // -> Hi! }) ``` ### `universalify.fromPromise(fn)` Takes a promise-based function to universalify, and returns the universalified function. Function must return a valid JS promise. `universalify` does not ensure that a valid promise is returned. ```js function promiseFn (n) { return new Promise(resolve => { setTimeout(() => resolve(n), 15) }) } const fn = universalify.fromPromise(promiseFn) // Works with Promises: fn('Hello World!') .then(result => console.log(result)) // -> Hello World! .catch(error => console.error(error)) // Works with Callbacks: fn('Hi!', (error, result) => { if (error) return console.error(error) console.log(result) // -> Hi! }) ``` ## License MIT


زبان مورد نیاز

مقدار نام
14.0.0 Npm


نحوه نصب


نصب پکیج tgz universalify-2.0.0:

    npm install universalify-2.0.0.tgz