source: imaps-frontend/node_modules/es-abstract/helpers/assertRecord.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[d565449]1'use strict';
2
3// TODO, semver-major: delete this
4
5var $TypeError = require('es-errors/type');
6var $SyntaxError = require('es-errors/syntax');
7
8var isMatchRecord = require('./records/match-record');
9var isPropertyDescriptor = require('./records/property-descriptor');
10var isIteratorRecord = require('./records/iterator-record');
11var isPromiseCapabilityRecord = require('./records/promise-capability-record');
12var isAsyncGeneratorRequestRecord = require('./records/async-generator-request-record');
13var isRegExpRecord = require('./records/regexp-record');
14
15var predicates = {
16 'Property Descriptor': isPropertyDescriptor,
17 'Match Record': isMatchRecord,
18 'Iterator Record': isIteratorRecord,
19 'PromiseCapability Record': isPromiseCapabilityRecord,
20 'AsyncGeneratorRequest Record': isAsyncGeneratorRequestRecord,
21 'RegExp Record': isRegExpRecord
22};
23
24module.exports = function assertRecord(Type, recordType, argumentName, value) {
25 var predicate = predicates[recordType];
26 if (typeof predicate !== 'function') {
27 throw new $SyntaxError('unknown record type: ' + recordType);
28 }
29 if (!predicate(value)) {
30 throw new $TypeError(argumentName + ' must be a ' + recordType);
31 }
32};
Note: See TracBrowser for help on using the repository browser.