This commit is contained in:
2024-11-03 17:16:20 +01:00
commit fd6412d6f2
8090 changed files with 778406 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
'use strict';
var hasOwn = require('hasown');
var isPromiseCapabilityRecord = require('./promise-capability-record');
module.exports = function isAsyncGeneratorRequestRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[Completion]]') // TODO: confirm is a completion record
&& hasOwn(value, '[[Capability]]')
&& isPromiseCapabilityRecord(value['[[Capability]]']);
};

View File

@@ -0,0 +1,18 @@
'use strict';
var hasOwn = require('hasown');
var isDataView = require('is-data-view');
var isInteger = require('../isInteger');
module.exports = function isDataViewWithBufferWitnessRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[Object]]')
&& hasOwn(value, '[[CachedBufferByteLength]]')
&& (
(isInteger(value['[[CachedBufferByteLength]]']) && value['[[CachedBufferByteLength]]'] >= 0)
|| value['[[CachedBufferByteLength]]'] === 'DETACHED'
)
&& isDataView(value['[[Object]]']);
};

View File

@@ -0,0 +1,13 @@
'use strict';
var hasOwn = require('hasown');
module.exports = function isIteratorRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[Iterator]]')
&& hasOwn(value, '[[NextMethod]]')
&& typeof value['[[NextMethod]]'] === 'function'
&& hasOwn(value, '[[Done]]')
&& typeof value['[[Done]]'] === 'boolean';
};

View File

@@ -0,0 +1,18 @@
'use strict';
var hasOwn = require('hasown');
// https://262.ecma-international.org/13.0/#sec-match-records
module.exports = function isMatchRecord(record) {
return (
!!record
&& typeof record === 'object'
&& hasOwn(record, '[[StartIndex]]')
&& hasOwn(record, '[[EndIndex]]')
&& record['[[StartIndex]]'] >= 0
&& record['[[EndIndex]]'] >= record['[[StartIndex]]']
&& String(parseInt(record['[[StartIndex]]'], 10)) === String(record['[[StartIndex]]'])
&& String(parseInt(record['[[EndIndex]]'], 10)) === String(record['[[EndIndex]]'])
);
};

View File

@@ -0,0 +1,16 @@
'use strict';
var hasOwn = require('hasown');
module.exports = function isPromiseCapabilityRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[Resolve]]')
&& typeof value['[[Resolve]]'] === 'function'
&& hasOwn(value, '[[Reject]]')
&& typeof value['[[Reject]]'] === 'function'
&& hasOwn(value, '[[Promise]]')
&& !!value['[[Promise]]']
&& typeof value['[[Promise]]'] === 'object'
&& typeof value['[[Promise]]'].then === 'function';
};

View File

@@ -0,0 +1,36 @@
'use strict';
var $TypeError = require('es-errors/type');
var hasOwn = require('hasown');
var allowed = {
__proto__: null,
'[[Configurable]]': true,
'[[Enumerable]]': true,
'[[Get]]': true,
'[[Set]]': true,
'[[Value]]': true,
'[[Writable]]': true
};
// https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type
module.exports = function isPropertyDescriptor(Desc) {
if (!Desc || typeof Desc !== 'object') {
return false;
}
for (var key in Desc) { // eslint-disable-line
if (hasOwn(Desc, key) && !allowed[key]) {
return false;
}
}
var isData = hasOwn(Desc, '[[Value]]') || hasOwn(Desc, '[[Writable]]');
var IsAccessor = hasOwn(Desc, '[[Get]]') || hasOwn(Desc, '[[Set]]');
if (isData && IsAccessor) {
throw new $TypeError('Property Descriptors may not be both accessor and data descriptors');
}
return true;
};

View File

@@ -0,0 +1,23 @@
'use strict';
var hasOwn = require('hasown');
var isInteger = require('../isInteger');
module.exports = function isRegExpRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[IgnoreCase]]')
&& typeof value['[[IgnoreCase]]'] === 'boolean'
&& hasOwn(value, '[[Multiline]]')
&& typeof value['[[Multiline]]'] === 'boolean'
&& hasOwn(value, '[[DotAll]]')
&& typeof value['[[DotAll]]'] === 'boolean'
&& hasOwn(value, '[[Unicode]]')
&& typeof value['[[Unicode]]'] === 'boolean'
&& hasOwn(value, '[[CapturingGroupsCount]]')
&& typeof value['[[CapturingGroupsCount]]'] === 'number'
&& isInteger(value['[[CapturingGroupsCount]]'])
&& value['[[CapturingGroupsCount]]'] >= 0
&& (!hasOwn(value, '[[UnicodeSets]]') || typeof value['[[UnicodeSets]]'] === 'boolean'); // optional since it was added later
};

View File

@@ -0,0 +1,18 @@
'use strict';
var hasOwn = require('hasown');
var isTypedArray = require('is-typed-array');
var isInteger = require('../isInteger');
module.exports = function isTypedArrayWithBufferWitnessRecord(value) {
return !!value
&& typeof value === 'object'
&& hasOwn(value, '[[Object]]')
&& hasOwn(value, '[[CachedBufferByteLength]]')
&& (
(isInteger(value['[[CachedBufferByteLength]]']) && value['[[CachedBufferByteLength]]'] >= 0)
|| value['[[CachedBufferByteLength]]'] === 'DETACHED'
)
&& isTypedArray(value['[[Object]]']);
};