Gathering detailed insights and metrics for aveazul
Gathering detailed insights and metrics for aveazul
Gathering detailed insights and metrics for aveazul
Gathering detailed insights and metrics for aveazul
npm install aveazul
Typescript
Module System
Min. Node Version
Node Version
NPM Version
73.8
Supply Chain
98.3
Quality
81.3
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
1,380
Last Day
1
Last Week
29
Last Month
447
Last Year
1,380
NOASSERTION License
1 Stars
55 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Jun 01, 2025
Latest Version
1.0.2
Package Id
aveazul@1.0.2
Unpacked Size
46.47 kB
Size
12.81 kB
File Count
12
NPM Version
11.3.0
Node Version
24.0.1
Published on
Jun 01, 2025
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
-71.6%
29
Compared to previous week
Last Month
59.1%
447
Compared to previous month
Last Year
0%
1,380
Compared to previous year
2
AveAzul ("Blue Bird" in Spanish) serves as a near drop-in replacement for Bluebird. It's built on native Promise, by extending it with the familiar utility methods from Bluebird.
The primary goal is to help migrate legacy code, that uses Bluebird APIs extensively, to native Promises. While not a 100% drop-in replacement (some aspects of Bluebird simply can't be replicated), it offers a practical migration path with minimal changes for most cases.
Further, if you like Bluebird's API but want to use native Promises, AveAzul gives you both - familiar Bluebird methods built on native Promise.
1npm install aveazul
1const AveAzul = require("aveazul"); 2 3// Basic Promise usage 4const promise = new AveAzul((resolve) => resolve(42)); 5promise.then((value) => console.log(value)); // 42 6 7// Utility methods 8AveAzul.resolve([1, 2, 3]) 9 .map((x) => x * 2) 10 .filter((x) => x > 2) 11 .then((result) => console.log(result)); // [4, 6] 12 13// Wait for at least 2 promises to be fulfilled 14const fetchUrls = [ 15 fetch("https://api.example.com/data1"), 16 fetch("https://api.example.com/data2"), 17 fetch("https://api.example.com/data3"), 18 fetch("https://api.example.com/data4"), 19]; 20AveAzul.some(fetchUrls, 2).then((results) => 21 console.log(`Got the first 2 successful results`) 22); 23 24// Process items sequentially with mapSeries 25AveAzul.resolve([1, 2, 3]) 26 .mapSeries(async (x) => { 27 // Each item is processed only after the previous one completes 28 await new Promise((resolve) => setTimeout(resolve, 100)); 29 return x * 2; 30 }) 31 .then((result) => console.log(result)); // [2, 4, 6] 32 33// Promisify callback-style functions 34const fs = require("fs"); 35const readFile = AveAzul.promisify(fs.readFile); 36readFile("file.txt").then((content) => console.log(content)); 37// Properties from the original function are preserved 38console.log(readFile.length); // Original function's length property 39 40// Promisify all methods of an object 41const obj = { 42 method(cb) { 43 cb(null, "result"); 44 }, 45}; 46AveAzul.promisifyAll(obj); 47obj.methodAsync().then((result) => console.log(result)); // 'result' 48 49// Resource management with disposer and using 50const getResource = () => { 51 return AveAzul.resolve({ 52 data: "important data", 53 close: () => console.log("Resource closed!"), 54 }).disposer((resource) => resource.close()); 55}; 56 57AveAzul.using(getResource(), (resource) => { 58 console.log(resource.data); // "important data" 59 return AveAzul.resolve("operation completed"); 60}).then((result) => { 61 console.log(result); // "operation completed" 62 // Resource is automatically closed here, even if an error occurred 63}); 64 65// Using spread to apply array results as arguments 66AveAzul.all([getUser(1), getPosts(1), getComments(1)]).spread( 67 (user, posts, comments) => { 68 // Instead of using .then(([user, posts, comments]) => {...}) 69 console.log( 70 `User ${user.name} has ${posts.length} posts and ${comments.length} comments` 71 ); 72 return { user, activity: { posts, comments } }; 73 } 74);
For most applications, migrating from Bluebird to AveAzul should be as simple as:
1// From 2const Promise = require("bluebird"); 3 4// To 5const Promise = require("aveazul");
Key differences to be aware of:
tap(fn)
- Execute side effects and return original valuefilter(fn)
- Filter array elementsmap(fn)
- Transform array elementsmapSeries(fn)
- Transform array elements sequentiallyreturn(value)
- Inject a new valueeach(fn)
- Iterate over array elementsdelay(ms)
- Delay resolutiontimeout(ms, message?)
- Reject after specified timeprops(obj)
- Resolve object propertiesspread(fn)
- Apply array values as arguments to functiontapCatch(fn)
- Execute side effects on rejectionreduce(fn, initialValue?)
- Reduce array elementssome(count)
- Resolves when a specified number of promises in the array have resolvedthrow(reason)
- Return rejected promisecatchThrow(reason)
- Catch and throw new errorcatchReturn(value)
- Catch and return valueget(propertyPath)
- Retrieve property valuedisposer(fn)
- Create a disposer for use with AveAzul.using() for resource cleanupany()
- Resolves when any promise in the iterable resolves, rejecting if all rejectall()
- Like Promise.all(), resolves when all promises resolve, rejects if any rejectcall(propertyName, ...args)
- Call a method on the resolved value with the provided argumentsasCallback(callback, options?)
- Register a Node-style callback that handles the resolution or rejectionerror(handler)
- Like catch(), but only catches operational errors, letting programmer errors bubble updelay(ms, value?)
- Resolve after specified timemap(value, fn)
- Transform array elementsmapSeries(value, fn)
- Transform array elements one at a time in sequencetry(fn)
- Wrap sync/async functionsprops(obj)
- Resolve object propertiesdefer()
- Create a deferred promisepromisify(fn, options?)
- Convert callback-style functions to promises (preserves original function properties)fromNode(fn, options?)
- Convert Node-style callback functions to promise-returning functionsfromCallback(fn, options?)
- Alias for fromNodeeach(items, fn)
- Iterate over array elementsreduce(array, fn, initialValue?)
- Reduce array elementssome(promises, count)
- Wait for a specified number of promises to be fulfilledmethod(fn)
- Creates a method that returns a promise resolving to the value returned by the original functionthrow(reason)
- Return rejected promisepromisifyAll(target, options?)
- Convert all methods of an object/class to promisesusing(resources, fn)
- Manage resources with automatic cleanupjoin(...values, handler?)
- Wait for multiple promises and pass their resolved values as separate arguments to the handler function. If no handler is provided, behaves like Promise.allAveAzul.OperationalError
- Error type for representing expected operational errors (network failures, validation errors, etc.)suffix
(default: 'Async') - Suffix to append to promisified method namesfilter
- Filter function to determine which methods to promisifypromisifier
- Custom function to handle promisificationmultiArgs
(default: false) - Whether to support multiple callback arguments1# Install dependencies 2npm install 3 4# Run tests 5npm test 6npm run test:watch 7npm run test:coverage 8 9# Test against Bluebird for compatibility 10npm run jest:bluebird -- test/[name].test.js
Contributions are welcome! Please feel free to submit a Pull Request.
Apache-2.0
Joel Chen, with assistant from Cursor Claude-3.7-sonnet
No vulnerabilities found.