Skip to content

Commit

Permalink
Renaming promisify() to all()
Browse files Browse the repository at this point in the history
  • Loading branch information
Brielle Harrison committed Oct 28, 2022
1 parent 76480bc commit b7232df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Observable.js
Expand Up @@ -315,21 +315,21 @@ export class Observable {
}));
}

async promisify() {
async all() {
let promise = new Promise((resolve, reject) => {
this
.reduce((previous, current) => {
previous.push(current);
return previous;
}, [])
}, [])
.subscribe(o => resolve(o), e => reject(e));
});

return promise;
}

async *[Symbol.asyncIterator]() {
let values = await this.promisify()
let values = await this.all()
for (let value of values) {
yield new Promise((resolve, _) => resolve(value))
}
Expand Down
8 changes: 4 additions & 4 deletions test/promisify.js → test/all.js
@@ -1,10 +1,10 @@
import assert from 'assert';

describe('promisify', ()=> {
it('should receive all the observed values in order as an array', async ()=>{
describe('all', ()=> {
it('should receive all the observed values in order as an array', async () => {
let observable = Observable.of(1,2,3,4);
let values = await observable.promisify();
let values = await observable.all();

assert.deepEqual([1,2,3,4], values);
});
});
});

0 comments on commit b7232df

Please sign in to comment.