5.20.119 • Published 11 months ago

@diotoborg/dolores-praesentium-assumenda v5.20.119

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@diotoborg/dolores-praesentium-assumenda

Make a callback-based or promise-based functions to support both promises and callbacks. Uses the native promise implementation. with typescript support.

npm Package License

Installation

npm i @diotoborg/dolores-praesentium-assumenda

Import or Require

import ppc from "@diotoborg/dolores-praesentium-assumenda";
OR
import {fromCallback,fromPromise} from "@diotoborg/dolores-praesentium-assumenda";
OR
const ppc = require("@diotoborg/dolores-praesentium-assumenda");
OR
const fromCallback = require("@diotoborg/dolores-praesentium-assumenda");
OR
const fromPromise = require("@diotoborg/dolores-praesentium-assumenda");

Here is an example usage of fromCallback function:

Suppose you have an asynchronous function readFile that reads a file and takes a callback as the last argument:

function readFile(filename, callback) {
  // Asynchronous operation to read file
}

You can convert this function to return a Promise with fromCallback function as follows:

import {fromCallback} from "@diotoborg/dolores-praesentium-assumenda";

const readFilePromise = fromCallback(readFile);

// You can now call the function with a Promise:
readFilePromise(filename)
  .then((data) => console.log(data))
  .catch((err) => console.error(err));

// Or with a callback:
readFilePromise(filename, (err, data) => {
  if (err) {
    console.error(err);
  } else {
    console.log(data);
  }
});

This allows you to use the same function in either Promise-based or callback-based code.

Here is an example usage of fromPromise function:

Suppose we have a function getUser that returns a promise:

function getUser(userId) {
  return new Promise((resolve, reject) => {
    // some async operation to fetch user
    setTimeout(() => {
      if (userId === '123') {
        resolve({ id: '123', name: 'John Doe' });
      } else {
        reject(new Error('User not found'));
      }
    }, 100);
  });
}

We can use fromPromise to create a function that can be called with a callback:

import {fromPromise} from "@diotoborg/dolores-praesentium-assumenda";

const getUserCallback = fromPromise(getUser);

getUserCallback('123', (err, user) => {
  if (err) {
    console.error(err);
  } else {
    console.log(user); // { id: '123', name: 'John Doe' }
  }
});

In the above example, the getUserCallback function accepts a callback as its last argument. If a callback is provided, it calls the original getUser function with the provided arguments and passes the result or error to the callback. If no callback is provided, it returns a promise.

We can also call getUserCallback without a callback to get a promise:

getUserCallback('123')
  .then(user => console.log(user)) // { id: '123', name: 'John Doe' }
  .catch(err => console.error(err));

License

@diotoborg/dolores-praesentium-assumenda is licensed under the MIT License.

statefindLastcommanderbrowserslistsafeforEachtapObject.getPrototypeOfless compilerbeanstalkextendfluxtrimLeftstoragegatewayclass-validatorloadbalancingtyped arraydropboundcomputed-typesprotocol-bufferseventDispatcher.envwafsimpledbcsswhichamazonvalidationsidecharacterlook-uptypeerrorstylingecmascriptFloat32Arraymoduleslockfilecompile lesscreatedotenvpolyfilltypeofdefinePushpluginkoreanmapspecprettydescriptorpackagesidIteratorECMAScript 2020higher-orderfastclonenopeerroragentSymbol.toStringTaglint@@toStringTagwordbreaksqsECMAScript 2021importexportwebES7batchunicodeuuidECMAScript 2022route53lruwarningUint32Arraysliceinstallerpreprocessorcss lessworkflowiterateECMAScript 3globqses6watchingzeromime-dbES2019eventsrequireESnextnodejsgraphqlrmdirlocationcheckstyleguideBigInt64ArraypositiveapollottyautoprefixergroupBycloudformationless cssloadinggroupgenericsObjectquotefilesequencesomeescaperegular expressionawaitObservablegetintrinsicpnpm9styleelectronTypeBoxshimelbtslibUint8Arrayclassnamesflaginstalles2016slotdependenciesES2016findwritecolumnindicatorcall-boundauthdefinePropertytypescriptvariablesfunctionfunctionalfastifydescriptionhardlinksiscomparestringfindLastIndexnumberchannelarktypeECMAScript 2019css variableurlArray.prototype.flattenES2015loggingfullwidthcore-jsoncees-shimsbcryptthrottleclassesvisualtoobjectartstructuredClonekinesisrecursiveflatMapyupwritableURLObject.keysmkdirformatstringifyreuseownreal-timeimportphoneencryptiondataViewlimitauthenticationfast-copytakefastcopyJSONArraybundlerparentschaihotconsumeformsECMAScript 5estreepropertygetOwnPropertyDescriptorvaluetelephonecallboundlivemakewaitlazyexecRegExp.prototype.flagsrm -rfECMAScript 6schemeassertratecoercibleES6ES2022mobileremovevpcspinnerObject.definePropertyReactiveXjsdom256toArrayintrinsicargumentratelimitmatchesidlereduxduplexgeteslintplugin_.extendcloudwatchArrayBuffer#sliceresolvepushsortworkerutilityproxylinkArrayBuffer.prototype.slicefastrdsbufferlinewrapvalidateTypeScriptECMAScript 2015a11yes2015dynamodbcircularObject.valuescallbindtoStringTagsnsconcatMapcommand-linelibphonenumbereslintsettingspromisejsxstdlibStreambytedeepcopytspicomatchmrucloudsearchkeyssortedSymbolfast-deep-copyserializationswfcloudfrontpackagerm -frtypedBigUint64Arrayimmernegative zeroclone
@diotoborg/vero-atque@diotoborg/vero-eligendi-deleniti@diotoborg/vero-quaerat@diotoborg/vero-sit-doloribus@diotoborg/vitae-quo@diotoborg/voluptate-eius@diotoborg/voluptate-fuga@diotoborg/voluptate-sequi-natus@diotoborg/voluptatum-veritatis@diotoborg/voluptatum-voluptas-enim@diotoborg/a-odio@diotoborg/ad-non@diotoborg/atque-dolorem-ratione@diotoborg/consectetur-consequuntur@diotoborg/consectetur-fuga@diotoborg/consectetur-modi-reprehenderit@diotoborg/consequatur-aut@diotoborg/consequatur-sunt@diotoborg/consequatur-velit-quae@diotoborg/consequuntur-dolorem-dicta@diotoborg/consequuntur-laboriosam@diotoborg/consequuntur-laborum@diotoborg/corporis-labore@diotoborg/enim-veritatis@diotoborg/esse-distinctio-repellat@diotoborg/est-beatae@diotoborg/et-maxime-hic@diotoborg/eum-porro@diotoborg/eum-tempora-distinctio@diotoborg/excepturi-incidunt@diotoborg/facilis-pariatur@diotoborg/et-voluptatum-mollitia@diotoborg/eveniet-officia@diotoborg/exercitationem-culpa@diotoborg/explicabo-optio@diotoborg/facilis-unde@diotoborg/fuga-molestias@diotoborg/fuga-nihil@diotoborg/esse-perspiciatis-voluptatem@diotoborg/et-facere-iusto@diotoborg/eum-est-nulla@diotoborg/excepturi-deserunt-eaque@diotoborg/et-architecto@diotoborg/eveniet-magnam@diotoborg/explicabo-nam-iste@diotoborg/fuga-rem-inventore@diotoborg/est-necessitatibus@diotoborg/eum-deleniti-tempora@diotoborg/eveniet-eaque-fugit@diotoborg/explicabo-laboriosam-maxime@diotoborg/explicabo-vitae-velit@diotoborg/eos-quidem@diotoborg/error-nesciunt-qui@diotoborg/est-voluptate@diotoborg/eveniet-pariatur-esse@diotoborg/explicabo-pariatur@diotoborg/ex-repellat@diotoborg/facilis-perferendis@diotoborg/corporis-voluptatum-saepe@diotoborg/dignissimos-officiis@diotoborg/distinctio-quaerat@diotoborg/distinctio-quia@diotoborg/dolore-odio-est@diotoborg/dolorum-saepe@diotoborg/earum-eligendi@diotoborg/corporis-repellat-dicta@diotoborg/deleniti-totam-suscipit@diotoborg/dolor-iure@diotoborg/dolorem-dolorem@diotoborg/dolores-velit@diotoborg/doloribus-error@diotoborg/eaque-iusto@diotoborg/eius-pariatur@diotoborg/cum-aliquam@diotoborg/cupiditate-perferendis-repudiandae@diotoborg/ea-consectetur@diotoborg/ducimus-eveniet@diotoborg/dolorum-unde@diotoborg/corporis-quia@diotoborg/corporis-optio-tenetur@diotoborg/debitis-blanditiis-dolore@diotoborg/deserunt-eum@diotoborg/dolore-nesciunt@diotoborg/dolorum-tempora@diotoborg/eius-animi-ullam@diotoborg/earum-eum-doloribus@diotoborg/culpa-at-cumque@diotoborg/cumque-repellat@diotoborg/cumque-velit-eius@diotoborg/dignissimos-aliquam@diotoborg/distinctio-sed@diotoborg/dolorem-possimus@diotoborg/eaque-illum-qui@diotoborg/corrupti-beatae@diotoborg/culpa-amet-totam@diotoborg/cupiditate-accusantium-provident@diotoborg/distinctio-excepturi@diotoborg/dolore-id@diotoborg/eaque-maxime@diotoborg/cum-illum
5.20.119

11 months ago

5.19.115

12 months ago

5.19.111

12 months ago

5.19.112

12 months ago

2.12.49

1 year ago

5.19.113

12 months ago

2.12.48

1 year ago

5.19.114

12 months ago

2.12.47

1 year ago

2.12.46

1 year ago

2.12.45

1 year ago

2.12.44

1 year ago

3.16.70

1 year ago

4.18.80

1 year ago

4.18.81

1 year ago

2.10.36

1 year ago

4.18.82

1 year ago

2.10.37

1 year ago

4.18.83

1 year ago

2.10.38

1 year ago

4.18.84

1 year ago

2.10.39

1 year ago

2.8.33

1 year ago

4.18.85

1 year ago

2.3.22

1 year ago

4.18.86

1 year ago

2.3.21

1 year ago

4.18.87

1 year ago

4.18.88

1 year ago

4.18.89

1 year ago

3.16.71

1 year ago

2.14.56

1 year ago

2.10.40

1 year ago

2.14.54

1 year ago

2.10.41

1 year ago

2.14.55

1 year ago

2.1.14

1 year ago

2.1.15

1 year ago

4.18.72

1 year ago

4.18.73

1 year ago

4.18.74

1 year ago

4.18.75

1 year ago

4.18.76

1 year ago

4.18.77

1 year ago

4.18.78

1 year ago

4.18.79

1 year ago

4.19.111

12 months ago

4.19.110

12 months ago

2.15.59

1 year ago

2.15.57

1 year ago

2.15.58

1 year ago

2.15.56

1 year ago

2.6.30

1 year ago

3.16.69

1 year ago

3.16.68

1 year ago

2.12.53

1 year ago

2.12.52

1 year ago

2.12.51

1 year ago

2.12.50

1 year ago

2.4.24

1 year ago

3.16.67

1 year ago

2.9.34

1 year ago

3.16.66

1 year ago

2.9.35

1 year ago

3.16.65

1 year ago

2.4.23

1 year ago

3.16.64

1 year ago

2.9.33

1 year ago

2.4.22

1 year ago

3.16.63

1 year ago

3.16.62

1 year ago

3.16.61

1 year ago

2.9.36

1 year ago

3.16.60

1 year ago

2.11.41

1 year ago

2.13.54

1 year ago

2.11.42

1 year ago

2.2.17

1 year ago

2.13.53

1 year ago

2.11.43

1 year ago

2.2.18

1 year ago

2.11.44

1 year ago

2.2.15

1 year ago

2.2.16

1 year ago

4.17.71

1 year ago

4.17.72

1 year ago

2.2.19

1 year ago

4.18.107

12 months ago

4.18.106

12 months ago

4.18.105

12 months ago

4.18.104

12 months ago

5.20.117

12 months ago

4.18.109

12 months ago

2.15.60

1 year ago

5.20.118

12 months ago

4.18.108

12 months ago

2.7.33

1 year ago

2.2.20

1 year ago

2.7.32

1 year ago

2.2.21

1 year ago

2.7.31

1 year ago

2.7.30

1 year ago

4.18.103

12 months ago

4.18.102

12 months ago

4.18.101

1 year ago

4.18.100

1 year ago

5.20.115

12 months ago

5.20.116

12 months ago

2.5.29

1 year ago

2.5.25

1 year ago

2.5.26

1 year ago

2.5.27

1 year ago

2.5.28

1 year ago

4.18.110

12 months ago

2.16.60

1 year ago

2.5.24

1 year ago

3.17.71

1 year ago

4.18.90

1 year ago

4.18.91

1 year ago

4.18.92

1 year ago

4.18.93

1 year ago

4.18.94

1 year ago

4.18.95

1 year ago

4.18.96

1 year ago

4.18.97

1 year ago

4.18.98

1 year ago

4.18.99

1 year ago

2.5.30

1 year ago

2.1.13

1 year ago

2.1.12

1 year ago

1.1.12

1 year ago

1.0.11

1 year ago

1.1.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago