Skip to content

Commit

Permalink
fix(scopes): Added filter method
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfede committed Mar 24, 2017
1 parent d2344f4 commit ce97477
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export class Scopes {
}
return true;
}
/* TODO currently not used
filter(_scopes: string | string[] | Scopes): Scopes {
let scopes: Scopes;
if (typeof _scopes === 'string' || Array.isArray(_scopes)) {
Expand All @@ -97,5 +96,4 @@ export class Scopes {
}
return out;
}
*/
}
7 changes: 7 additions & 0 deletions test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,13 @@ describe('API', function() {
should.throw(function() { let s = new Scopes(['']); }, RangeError);
});

it('should filter scopes', function() {
let ref = new Scopes([ 'a.*', '-a.x', '*.z' ]);
ref.filter('a.x a.y c.x c.y c.z').toArray().should.deep.equal(['a.y', 'c.z']);
ref.filter([ 'a.x', 'a.y', 'c.x', 'c.y', 'c.z' ]).toArray().should.deep.equal(['a.y', 'c.z']);
ref.filter(new Scopes([ 'a.x', 'a.y', 'c.x', 'c.y', 'c.z' ])).toArray().should.deep.equal(['a.y', 'c.z']);
});

});


Expand Down

0 comments on commit ce97477

Please sign in to comment.