aveazul 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +63 -50
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,18 +1,6 @@
1
1
  # AveAzul
2
2
 
3
- AveAzul ("Blue Bird" in Spanish) is a Promise extension library that provides Bluebird-like utility methods built on top of native Promises. The name is a Spanish play on words referencing Bluebird.
4
-
5
- ## Requirements
6
-
7
- - Node.js 16 or higher
8
-
9
- ## Features
10
-
11
- - Extends native Promise with Bluebird-like utility methods
12
- - Built on top of the efficient `xaa` library for async operations
13
- - Zero external runtime dependencies (other than `xaa`)
14
- - TypeScript-friendly
15
- - Familiar Bluebird-style API
3
+ AveAzul ("Blue Bird" in Spanish) is a Promise library that extends native Promises with Bluebird-like utility methods. Built on top of native Promises, it provides a familiar API for Node.js developers who are used to working with [Bluebird](https://github.com/petkaantonov/bluebird) ([npm](https://www.npmjs.com/package/bluebird)).
16
4
 
17
5
  ## Installation
18
6
 
@@ -25,63 +13,88 @@ npm install aveazul
25
13
  ```javascript
26
14
  const AveAzul = require('aveazul');
27
15
 
28
- // Create a new promise
29
- const promise = new AveAzul((resolve, reject) => {
30
- setTimeout(() => resolve('result'), 1000);
31
- });
16
+ // Basic Promise usage
17
+ const promise = new AveAzul((resolve) => resolve(42));
18
+ promise.then(value => console.log(value)); // 42
32
19
 
33
- // Use Bluebird-style methods
34
- promise
35
- .tap(value => console.log('Got:', value))
36
- .delay(500)
37
- .then(value => console.log('After delay:', value));
38
-
39
- // Static helpers
40
- AveAzul.delay(1000, 'hello')
41
- .then(value => console.log(value));
42
-
43
- // Array operations
20
+ // Utility methods
44
21
  AveAzul.resolve([1, 2, 3])
45
22
  .map(x => x * 2)
46
- .filter(x => x > 4)
47
- .then(result => console.log(result)); // [6]
23
+ .filter(x => x > 2)
24
+ .then(result => console.log(result)); // [4, 6]
25
+
26
+ // Promisify callback-style functions
27
+ const fs = require('fs');
28
+ const readFile = AveAzul.promisify(fs.readFile);
29
+ readFile('file.txt').then(content => console.log(content));
30
+
31
+ // Promisify all methods of an object
32
+ const obj = {
33
+ method(cb) { cb(null, 'result'); }
34
+ };
35
+ AveAzul.promisifyAll(obj);
36
+ obj.methodAsync().then(result => console.log(result)); // 'result'
48
37
  ```
49
38
 
50
39
  ## API
51
40
 
52
41
  ### Instance Methods
53
42
 
54
- - `tap(fn)` - Execute side effects in a chain
43
+ - `tap(fn)` - Execute side effects and return original value
55
44
  - `filter(fn)` - Filter array elements
56
- - `map(fn)` - Map array elements
57
- - `return(value)` - Inject a value into the chain
45
+ - `map(fn)` - Transform array elements
46
+ - `return(value)` - Inject a new value
58
47
  - `each(fn)` - Iterate over array elements
59
- - `delay(ms)` - Delay execution
60
- - `timeout(ms, message?)` - Set operation timeout
48
+ - `delay(ms)` - Delay resolution
49
+ - `timeout(ms, message?)` - Reject after specified time
61
50
  - `try(fn)` - Wrap sync/async functions
62
- - `props(obj)` - Handle object properties
63
- - `reduce(fn, initialValue?)` - Reduce array
51
+ - `props(obj)` - Resolve object properties
52
+ - `catchIf(predicate, fn)` - Catch specific errors
53
+ - `tapCatch(fn)` - Execute side effects on rejection
54
+ - `reduce(fn, initialValue?)` - Reduce array elements
64
55
  - `throw(reason)` - Return rejected promise
65
56
  - `catchThrow(reason)` - Catch and throw new error
66
57
  - `catchReturn(value)` - Catch and return value
67
- - `get(propertyPath)` - Get nested property
58
+ - `get(propertyPath)` - Retrieve property value
68
59
 
69
60
  ### Static Methods
70
61
 
71
- - `AveAzul.delay(ms, value?)` - Create delayed promise
72
- - `AveAzul.map(array, fn)` - Map array elements
73
- - `AveAzul.try(fn)` - Wrap function execution
74
- - `AveAzul.props(obj)` - Handle object properties
75
- - `AveAzul.defer()` - Create deferred promise
76
- - `AveAzul.promisify(fn, options?)` - Promisify callback functions
77
- - `AveAzul.each(items, fn)` - Iterate over items
78
- - `AveAzul.reduce(array, fn, initialValue?)` - Reduce array
79
- - `AveAzul.throw(reason)` - Create rejected promise
62
+ - `delay(ms, value?)` - Resolve after specified time
63
+ - `map(value, fn)` - Transform array elements
64
+ - `try(fn)` - Wrap sync/async functions
65
+ - `props(obj)` - Resolve object properties
66
+ - `defer()` - Create a deferred promise
67
+ - `promisify(fn, options?)` - Convert callback-style functions to promises
68
+ - `each(items, fn)` - Iterate over array elements
69
+ - `reduce(array, fn, initialValue?)` - Reduce array elements
70
+ - `throw(reason)` - Return rejected promise
71
+ - `promisifyAll(target, options?)` - Convert all methods of an object/class to promises
72
+
73
+ ### PromisifyAll Options
74
+
75
+ - `suffix` (default: 'Async') - Suffix to append to promisified method names
76
+ - `filter` - Filter function to determine which methods to promisify
77
+ - `promisifier` - Custom function to handle promisification
78
+ - `multiArgs` (default: false) - Whether to support multiple callback arguments
79
+ - `excludeMain` (default: false) - Whether to exclude promisifying the main object/class
80
+ - `context` - The context (this) to use when calling methods
81
+
82
+ ## Development
83
+
84
+ ```bash
85
+ # Install dependencies
86
+ npm install
87
+
88
+ # Run tests
89
+ npm test
90
+ npm run test:watch
91
+ npm run test:coverage
92
+ ```
80
93
 
81
94
  ## License
82
95
 
83
- Apache 2.0
96
+ Apache-2.0
84
97
 
85
- ## Dependencies
98
+ ## Author
86
99
 
87
- - [xaa](https://github.com/jchip/xaa) - Efficient async/await helpers
100
+ Joel Chen
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aveazul",
3
- "version": "0.1.2",
4
- "description": "Extend native Promise with bluebird like APIs for Node.js",
3
+ "version": "0.1.3",
4
+ "description": "Bluebird-like APIs in extended native Promise",
5
5
  "main": "lib/aveazul.js",
6
6
  "homepage": "https://github.com/jchip/aveazul",
7
7
  "license": "Apache-2.0",