kn-es-features 1.0.0 → 1.0.1
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.
package/dist/esfeatures.iife.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var EsFeatures=function(exports){"use strict";var _documentCurrentScript=typeof document<"u"?document.currentScript:null;function _arrayLikeToArray(o,n){(n==null||n>o.length)&&(n=o.length);for(var e=0,i=Array(n);e<n;e++)i[e]=o[e];return i}function _arrayWithHoles(o){if(Array.isArray(o))return o}function _arrayWithoutHoles(o){if(Array.isArray(o))return _arrayLikeToArray(o)}function _assertClassBrand(o,n,e){if(typeof o=="function"?o===n:o.has(n))return arguments.length<3?n:e;throw new TypeError("Private element is not present on this object")}function _assertThisInitialized(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}function asyncGeneratorStep(o,n,e,i,r,t,a){try{var s=o[t](a),u=s.value}catch(c){return void e(c)}s.done?n(u):Promise.resolve(u).then(i,r)}function _asyncToGenerator(o){return function(){var n=this,e=arguments;return new Promise(function(i,r){var t=o.apply(n,e);function a(u){asyncGeneratorStep(t,i,r,a,s,"next",u)}function s(u){asyncGeneratorStep(t,i,r,a,s,"throw",u)}a(void 0)})}}function _callSuper(o,n,e){return n=_getPrototypeOf(n),_possibleConstructorReturn(o,_isNativeReflectConstruct()?Reflect.construct(n,e||[],_getPrototypeOf(o).constructor):n.apply(o,e))}function _checkInRHS(o){if(Object(o)!==o)throw TypeError("right-hand side of 'in' should be an object, got "+(o!==null?typeof o:"null"));return o}function _checkPrivateRedeclaration(o,n){if(n.has(o))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classCallCheck(o,n){if(!(o instanceof n))throw new TypeError("Cannot call a class as a function")}function _classPrivateFieldGet2(o,n){return o.get(_assertClassBrand(o,n))}function _classPrivateFieldInitSpec(o,n,e){_checkPrivateRedeclaration(o,n),n.set(o,e)}function _classPrivateFieldSet2(o,n,e){return o.set(_assertClassBrand(o,n),e),e}function _classPrivateMethodInitSpec(o,n){_checkPrivateRedeclaration(o,n),n.add(o)}function _construct(o,n,e){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,n);var r=new(o.bind.apply(o,i));return e&&_setPrototypeOf(r,e.prototype),r}function _defineProperties(o,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(o,_toPropertyKey(i.key),i)}}function _createClass(o,n,e){return n&&_defineProperties(o.prototype,n),e&&_defineProperties(o,e),Object.defineProperty(o,"prototype",{writable:!1}),o}function _createForOfIteratorHelper(o,n){var e=typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(!e){if(Array.isArray(o)||(e=_unsupportedIterableToArray(o))||n&&o&&typeof o.length=="number"){e&&(o=e);var i=0,r=function(){};return{s:r,n:function(){return i>=o.length?{done:!0}:{done:!1,value:o[i++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t,a=!0,s=!1;return{s:function(){e=e.call(o)},n:function(){var u=e.next();return a=u.done,u},e:function(u){s=!0,t=u},f:function(){try{a||e.return==null||e.return()}finally{if(s)throw t}}}}function _defineProperty(o,n,e){return(n=_toPropertyKey(n))in o?Object.defineProperty(o,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):o[n]=e,o}function _get(){return _get=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(o,n,e){var i=_superPropBase(o,n);if(i){var r=Object.getOwnPropertyDescriptor(i,n);return r.get?r.get.call(arguments.length<3?o:e):r.value}},_get.apply(null,arguments)}function _getPrototypeOf(o){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},_getPrototypeOf(o)}function _inherits(o,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");o.prototype=Object.create(n&&n.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),Object.defineProperty(o,"prototype",{writable:!1}),n&&_setPrototypeOf(o,n)}function _isNativeFunction(o){try{return Function.toString.call(o).indexOf("[native code]")!==-1}catch{return typeof o=="function"}}function _isNativeReflectConstruct(){try{var o=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(_isNativeReflectConstruct=function(){return!!o})()}function _iterableToArray(o){if(typeof Symbol<"u"&&o[Symbol.iterator]!=null||o["@@iterator"]!=null)return Array.from(o)}function _iterableToArrayLimit(o,n){var e=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(e!=null){var i,r,t,a,s=[],u=!0,c=!1;try{if(t=(e=e.call(o)).next,n===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(i=t.call(e)).done)&&(s.push(i.value),s.length!==n);u=!0);}catch(l){c=!0,r=l}finally{try{if(!u&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw r}}return s}}function _nonIterableRest(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _nonIterableSpread(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
4
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ownKeys(o,n){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(o);n&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(o,r).enumerable})),e.push.apply(e,i)}return e}function _objectSpread2(o){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?ownKeys(Object(e),!0).forEach(function(i){_defineProperty(o,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(e)):ownKeys(Object(e)).forEach(function(i){Object.defineProperty(o,i,Object.getOwnPropertyDescriptor(e,i))})}return o}function _objectWithoutProperties(o,n){if(o==null)return{};var e,i,r=_objectWithoutPropertiesLoose(o,n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);for(i=0;i<t.length;i++)e=t[i],n.indexOf(e)===-1&&{}.propertyIsEnumerable.call(o,e)&&(r[e]=o[e])}return r}function _objectWithoutPropertiesLoose(o,n){if(o==null)return{};var e={};for(var i in o)if({}.hasOwnProperty.call(o,i)){if(n.indexOf(i)!==-1)continue;e[i]=o[i]}return e}function _possibleConstructorReturn(o,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(o)}function _regenerator(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var o,n,e=typeof Symbol=="function"?Symbol:{},i=e.iterator||"@@iterator",r=e.toStringTag||"@@toStringTag";function t(y,p,S,M){var I=p&&p.prototype instanceof s?p:s,R=Object.create(I.prototype);return _regeneratorDefine(R,"_invoke",function(F,T,N){var
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ownKeys(o,n){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(o);n&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(o,r).enumerable})),e.push.apply(e,i)}return e}function _objectSpread2(o){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?ownKeys(Object(e),!0).forEach(function(i){_defineProperty(o,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(e)):ownKeys(Object(e)).forEach(function(i){Object.defineProperty(o,i,Object.getOwnPropertyDescriptor(e,i))})}return o}function _objectWithoutProperties(o,n){if(o==null)return{};var e,i,r=_objectWithoutPropertiesLoose(o,n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);for(i=0;i<t.length;i++)e=t[i],n.indexOf(e)===-1&&{}.propertyIsEnumerable.call(o,e)&&(r[e]=o[e])}return r}function _objectWithoutPropertiesLoose(o,n){if(o==null)return{};var e={};for(var i in o)if({}.hasOwnProperty.call(o,i)){if(n.indexOf(i)!==-1)continue;e[i]=o[i]}return e}function _possibleConstructorReturn(o,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(o)}function _regenerator(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var o,n,e=typeof Symbol=="function"?Symbol:{},i=e.iterator||"@@iterator",r=e.toStringTag||"@@toStringTag";function t(y,p,S,M){var I=p&&p.prototype instanceof s?p:s,R=Object.create(I.prototype);return _regeneratorDefine(R,"_invoke",function(F,T,N){var _,h,d,P=0,k=N||[],A=!1,w={p:0,n:0,v:o,a:O,f:O.bind(o,4),d:function(b,m){return _=b,h=0,d=o,w.n=m,a}};function O(b,m){for(h=b,d=m,n=0;!A&&P&&!E&&n<k.length;n++){var E,g=k[n],j=w.p,C=g[2];b>3?(E=C===m)&&(d=g[(h=g[4])?5:(h=3,3)],g[4]=g[5]=o):g[0]<=j&&((E=b<2&&j<g[1])?(h=0,w.v=m,w.n=g[1]):j<C&&(E=b<3||g[0]>m||m>C)&&(g[4]=b,g[5]=m,w.n=C,h=0))}if(E||b>1)return a;throw A=!0,m}return function(b,m,E){if(P>1)throw TypeError("Generator is already running");for(A&&m===1&&O(m,E),h=m,d=E;(n=h<2?o:d)||!A;){_||(h?h<3?(h>1&&(w.n=-1),O(h,d)):w.n=d:w.v=d);try{if(P=2,_){if(h||(b="next"),n=_[b]){if(!(n=n.call(_,d)))throw TypeError("iterator result is not an object");if(!n.done)return n;d=n.value,h<2&&(h=0)}else h===1&&(n=_.return)&&n.call(_),h<2&&(d=TypeError("The iterator does not provide a '"+b+"' method"),h=1);_=o}else if((n=(A=w.n<0)?d:F.call(T,w))!==a)break}catch(g){_=o,h=1,d=g}finally{P=1}}return{value:n,done:A}}}(y,S,M),!0),R}var a={};function s(){}function u(){}function c(){}n=Object.getPrototypeOf;var l=[][i]?n(n([][i]())):(_regeneratorDefine(n={},i,function(){return this}),n),f=c.prototype=s.prototype=Object.create(l);function v(y){return Object.setPrototypeOf?Object.setPrototypeOf(y,c):(y.__proto__=c,_regeneratorDefine(y,r,"GeneratorFunction")),y.prototype=Object.create(f),y}return u.prototype=c,_regeneratorDefine(f,"constructor",c),_regeneratorDefine(c,"constructor",u),u.displayName="GeneratorFunction",_regeneratorDefine(c,r,"GeneratorFunction"),_regeneratorDefine(f),_regeneratorDefine(f,r,"Generator"),_regeneratorDefine(f,i,function(){return this}),_regeneratorDefine(f,"toString",function(){return"[object Generator]"}),(_regenerator=function(){return{w:t,m:v}})()}function _regeneratorDefine(o,n,e,i){var r=Object.defineProperty;try{r({},"",{})}catch{r=0}_regeneratorDefine=function(t,a,s,u){function c(l,f){_regeneratorDefine(t,l,function(v){return this._invoke(l,f,v)})}a?r?r(t,a,{value:s,enumerable:!u,configurable:!u,writable:!u}):t[a]=s:(c("next",0),c("throw",1),c("return",2))},_regeneratorDefine(o,n,e,i)}function _regeneratorValues(o){if(o!=null){var n=o[typeof Symbol=="function"&&Symbol.iterator||"@@iterator"],e=0;if(n)return n.call(o);if(typeof o.next=="function")return o;if(!isNaN(o.length))return{next:function(){return o&&e>=o.length&&(o=void 0),{value:o&&o[e++],done:!o}}}}throw new TypeError(typeof o+" is not iterable")}function _setPrototypeOf(o,n){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,i){return e.__proto__=i,e},_setPrototypeOf(o,n)}function _slicedToArray(o,n){return _arrayWithHoles(o)||_iterableToArrayLimit(o,n)||_unsupportedIterableToArray(o,n)||_nonIterableRest()}function _superPropBase(o,n){for(;!{}.hasOwnProperty.call(o,n)&&(o=_getPrototypeOf(o))!==null;);return o}function _superPropGet(o,n,e,i){var r=_get(_getPrototypeOf(1&i?o.prototype:o),n,e);return 2&i&&typeof r=="function"?function(t){return r.apply(e,t)}:r}function _taggedTemplateLiteral(o,n){return n||(n=o.slice(0)),Object.freeze(Object.defineProperties(o,{raw:{value:Object.freeze(n)}}))}function _toConsumableArray(o){return _arrayWithoutHoles(o)||_iterableToArray(o)||_unsupportedIterableToArray(o)||_nonIterableSpread()}function _toPrimitive(o,n){if(typeof o!="object"||!o)return o;var e=o[Symbol.toPrimitive];if(e!==void 0){var i=e.call(o,n||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(o)}function _toPropertyKey(o){var n=_toPrimitive(o,"string");return typeof n=="symbol"?n:n+""}function _typeof(o){"@babel/helpers - typeof";return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},_typeof(o)}function _unsupportedIterableToArray(o,n){if(o){if(typeof o=="string")return _arrayLikeToArray(o,n);var e={}.toString.call(o).slice(8,-1);return e==="Object"&&o.constructor&&(e=o.constructor.name),e==="Map"||e==="Set"?Array.from(o):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?_arrayLikeToArray(o,n):void 0}}function _wrapNativeSuper(o){var n=typeof Map=="function"?new Map:void 0;return _wrapNativeSuper=function(e){if(e===null||!_isNativeFunction(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(n!==void 0){if(n.has(e))return n.get(e);n.set(e,i)}function i(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(i,e)},_wrapNativeSuper(o)}function _wrapRegExp(){_wrapRegExp=function(r,t){return new e(r,void 0,t)};var o=RegExp.prototype,n=new WeakMap;function e(r,t,a){var s=RegExp(r,t);return n.set(s,a||n.get(r)),_setPrototypeOf(s,e.prototype)}function i(r,t){var a=n.get(t);return Object.keys(a).reduce(function(s,u){var c=a[u];if(typeof c=="number")s[u]=r[c];else{for(var l=0;r[c[l]]===void 0&&l+1<c.length;)l++;s[u]=r[c[l]]}return s},Object.create(null))}return _inherits(e,RegExp),e.prototype.exec=function(r){var t=o.exec.call(this,r);if(t){t.groups=i(t,this);var a=t.indices;a&&(a.groups=i(a,this))}return t},e.prototype[Symbol.replace]=function(r,t){if(typeof t=="string"){var a=n.get(this);return o[Symbol.replace].call(this,r,t.replace(/\$<([^>]+)(>|$)/g,function(u,c,l){if(l==="")return u;var f=a[c];return Array.isArray(f)?"$"+f.join("$"):typeof f=="number"?"$"+f:""}))}if(typeof t=="function"){var s=this;return o[Symbol.replace].call(this,r,function(){var u=arguments;return typeof u[u.length-1]!="object"&&(u=[].slice.call(u)).push(i(u,s)),t.apply(this,u)})}return o[Symbol.replace].call(this,r,t)},_wrapRegExp.apply(this,arguments)}function createSuite(o){var n=[];function e(t,a){try{var s=a();if(s instanceof Promise)return s.then(function(){n.push({suite:o,case:t,status:"pass"})}).catch(function(u){n.push({suite:o,case:t,status:"fail",error:u.message})});n.push({suite:o,case:t,status:"pass"})}catch(u){n.push({suite:o,case:t,status:"fail",error:u.message})}}function i(t,a){if(!t)throw new Error(a||"断言失败")}function r(){return n}return{test:e,assert:i,getResults:r}}function printResults(o){var n=0,e=0;o.forEach(function(i){i.status==="pass"?(n++,console.log(" ✓ [".concat(i.suite,"] ").concat(i.case))):(e++,console.error(" ✗ [".concat(i.suite,"] ").concat(i.case," — ").concat(i.error)))}),console.log(`
|
|
5
5
|
共 `.concat(o.length," 项,通过 ").concat(n,",失败 ").concat(e))}function testLetConst(){var o=createSuite("let & const"),n=o.test,e=o.assert,i=o.getResults;return n("let 块级作用域",function(){for(var r=[],t=0;t<3;t++)r.push(t);e(r[0]===0&&r[2]===2,"let 循环变量应为独立值")}),n("let 不可重复声明",function(){try{new Function('"use strict"; let x = 1; let x = 2;')(),e(!1,"应抛出 SyntaxError")}catch(r){e(r instanceof SyntaxError||r instanceof TypeError,"应为语法错误")}}),n("let 暂时性死区(TDZ)",function(){try{new Function('"use strict"; console.log(y); let y = 1;')(),e(!1,"应抛出 ReferenceError")}catch{e(!0)}}),n("const 声明常量",function(){var r=3.14159;e(r===3.14159,"const 值应保持不变")}),n("const 不可重新赋值",function(){try{new Function('"use strict"; const x = 1; x = 2;')(),e(!1,"应抛出 TypeError")}catch(r){e(r instanceof TypeError,"应为 TypeError")}}),n("const 对象属性可修改",function(){var r={a:1};r.a=2,e(r.a===2,"const 对象的属性可以修改")}),i()}function testArrowFunctions(){var o=createSuite("箭头函数"),n=o.test,e=o.assert,i=o.getResults;return n("基本语法",function(){var r=function(a,s){return a+s};e(r(2,3)===5,"箭头函数返回值应为 5")}),n("单参数省略括号",function(){var r=function(a){return a*2};e(r(4)===8,"单参数箭头函数应正常工作")}),n("无参数需要括号",function(){var r=function(){return"hello"};e(r()==="hello","无参数箭头函数应正常工作")}),n("多行函数体需要花括号和 return",function(){var r=function(a,s){var u=a+s;return u*2};e(r(2,3)===10,"多行箭头函数应正确计算")}),n("返回对象字面量需要括号",function(){var r=function(s){return{value:s}},t=r(42);e(t.value===42,"箭头函数返回对象应正确包裹")}),n("this 词法绑定",function(){function r(){var a=this;this.count=0;var s=function(){a.count++};s(),s()}var t=new r;e(t.count===2,"箭头函数 this 应绑定外层作用域")}),n("没有 arguments 对象",function(){e(!0,"箭头函数无独立 arguments")}),n("不能用作构造函数(原生环境)",function(){var r=function(){},t=r.prototype===void 0;if(t)try{new r,e(!1,"应抛出 TypeError")}catch(a){e(a instanceof TypeError,"箭头函数不能 new")}}),i()}var _templateObject,_templateObject2;function testTemplateLiterals(){var o=createSuite("模板字符串"),n=o.test,e=o.assert,i=o.getResults;return n("基本插值",function(){var r="ES2015",t="Hello, ".concat(r,"!");e(t==="Hello, ES2015!","模板字符串插值应正确")}),n("表达式插值",function(){var r=3,t=4,a="".concat(r," + ").concat(t," = ").concat(r+t);e(a==="3 + 4 = 7","模板字符串支持表达式")}),n("多行字符串",function(){var r=`第一行
|
|
6
6
|
第二行`;e(r.includes(`
|
|
7
7
|
`),"模板字符串支持多行")}),n("嵌套模板",function(){var r=["a","b","c"],t="items: ".concat(r.map(function(a){return"[".concat(a,"]")}).join(", "));e(t==="items: [a], [b], [c]","模板字符串可以嵌套")}),n("标签模板 - 基本用法",function(){function r(s){for(var u=arguments.length,c=new Array(u>1?u-1:0),l=1;l<u;l++)c[l-1]=arguments[l];return s.raw[0]+c[0].toUpperCase()}var t="world",a=r(_templateObject||(_templateObject=_taggedTemplateLiteral(["hello ",""])),t);e(a==="hello WORLD","标签模板应正确处理")}),n("标签模板 - String.raw",function(){var r=String.raw(_templateObject2||(_templateObject2=_taggedTemplateLiteral([`C:Users est
|
|
@@ -40,6 +40,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
40
40
|
}
|
|
41
41
|
log.push('after-block')
|
|
42
42
|
})()
|
|
43
|
-
`),l.n=2,c(u,Symbol);case 2:i(u[0]==="in-block","异步块内应正常执行"),i(u[1]==="async-disposed","await using 应等待异步 dispose 完成"),i(u[2]==="after-block","dispose 之后才继续执行块后代码");case 3:return l.a(2)}},s)}))),e("DisposableStack —— 手动管理资源栈",function(){if(typeof DisposableStack>"u"){i(!0,"(跳过:环境不支持 DisposableStack)");return}var s=[],u=new DisposableStack;u.defer(function(){return s.push("deferred-1")}),u.defer(function(){return s.push("deferred-2")}),u.dispose(),i(s.join(",")==="deferred-2,deferred-1","DisposableStack 应按 LIFO 执行")}),a.a(2,r())}},o)})),_testExplicitResourceManagement.apply(this,arguments)}function testAtomicsPause(){var o=createSuite("Atomics.pause() (ES2026)"),n=o.test,e=o.assert,i=o.getResults,r=typeof Atomics.pause=="function";return n("Atomics.pause 函数存在",function(){if(!r){e(!0,"(跳过:环境不支持 Atomics.pause)");return}e(typeof Atomics.pause=="function","Atomics.pause 应为函数")}),n("无参数调用不抛出错误",function(){if(!r){e(!0,"(跳过)");return}var t=!1;try{Atomics.pause()}catch{t=!0}e(!t,"Atomics.pause() 无参数调用不应抛出")}),n("传入整数参数不抛出错误",function(){if(!r){e(!0,"(跳过)");return}var t=!1;try{Atomics.pause(0),Atomics.pause(1),Atomics.pause(100)}catch{t=!0}e(!t,"Atomics.pause(N) 应接受非负整数参数")}),n("返回值为 undefined",function(){if(!r){e(!0,"(跳过)");return}e(Atomics.pause()===void 0,"Atomics.pause() 应返回 undefined")}),n("自旋等待模式下连续调用不崩溃",function(){if(!r){e(!0,"(跳过)");return}for(var t=0;t<10;t++)Atomics.pause(t);e(t===10,"10 次自旋循环应正常完成")}),n("与 SharedArrayBuffer + Atomics.load 配合(模拟场景)",function(){if(!r){e(!0,"(跳过)");return}if(typeof SharedArrayBuffer>"u"){e(!0,"(跳过:环境不支持 SharedArrayBuffer)");return}var t=new SharedArrayBuffer(4),a=new Int32Array(t);a[0]=1;for(var s=0,u=5;Atomics.load(a,0)!==0&&s<u;)Atomics.pause(s),s++,s===3&&Atomics.store(a,0,0);e(Atomics.load(a,0)===0,"自旋等待后标志位应变为 0(锁释放)"),e(s===3,"应在第 3 次迭代时检测到锁释放")}),i()}function testImportAttributes(){return _testImportAttributes.apply(this,arguments)}function _testImportAttributes(){return _testImportAttributes=_asyncToGenerator(_regenerator().m(function o(){var n,e,i,r,t;return _regenerator().w(function(a){for(;;)switch(a.n){case 0:return n=createSuite("Import Attributes (ES2026)"),e=n.test,i=n.assert,r=n.getResults,t=function(){try{return new Function("import('data:text/javascript,export default 1', { with: { type: 'javascript' } })"),!0}catch{return!1}}(),e("动态 import() 支持 with 选项对象",_asyncToGenerator(_regenerator().m(function s(){var u,c;return _regenerator().w(function(
|
|
43
|
+
`),l.n=2,c(u,Symbol);case 2:i(u[0]==="in-block","异步块内应正常执行"),i(u[1]==="async-disposed","await using 应等待异步 dispose 完成"),i(u[2]==="after-block","dispose 之后才继续执行块后代码");case 3:return l.a(2)}},s)}))),e("DisposableStack —— 手动管理资源栈",function(){if(typeof DisposableStack>"u"){i(!0,"(跳过:环境不支持 DisposableStack)");return}var s=[],u=new DisposableStack;u.defer(function(){return s.push("deferred-1")}),u.defer(function(){return s.push("deferred-2")}),u.dispose(),i(s.join(",")==="deferred-2,deferred-1","DisposableStack 应按 LIFO 执行")}),a.a(2,r())}},o)})),_testExplicitResourceManagement.apply(this,arguments)}function testAtomicsPause(){var o=createSuite("Atomics.pause() (ES2026)"),n=o.test,e=o.assert,i=o.getResults,r=typeof Atomics.pause=="function";return n("Atomics.pause 函数存在",function(){if(!r){e(!0,"(跳过:环境不支持 Atomics.pause)");return}e(typeof Atomics.pause=="function","Atomics.pause 应为函数")}),n("无参数调用不抛出错误",function(){if(!r){e(!0,"(跳过)");return}var t=!1;try{Atomics.pause()}catch{t=!0}e(!t,"Atomics.pause() 无参数调用不应抛出")}),n("传入整数参数不抛出错误",function(){if(!r){e(!0,"(跳过)");return}var t=!1;try{Atomics.pause(0),Atomics.pause(1),Atomics.pause(100)}catch{t=!0}e(!t,"Atomics.pause(N) 应接受非负整数参数")}),n("返回值为 undefined",function(){if(!r){e(!0,"(跳过)");return}e(Atomics.pause()===void 0,"Atomics.pause() 应返回 undefined")}),n("自旋等待模式下连续调用不崩溃",function(){if(!r){e(!0,"(跳过)");return}for(var t=0;t<10;t++)Atomics.pause(t);e(t===10,"10 次自旋循环应正常完成")}),n("与 SharedArrayBuffer + Atomics.load 配合(模拟场景)",function(){if(!r){e(!0,"(跳过)");return}if(typeof SharedArrayBuffer>"u"){e(!0,"(跳过:环境不支持 SharedArrayBuffer)");return}var t=new SharedArrayBuffer(4),a=new Int32Array(t);a[0]=1;for(var s=0,u=5;Atomics.load(a,0)!==0&&s<u;)Atomics.pause(s),s++,s===3&&Atomics.store(a,0,0);e(Atomics.load(a,0)===0,"自旋等待后标志位应变为 0(锁释放)"),e(s===3,"应在第 3 次迭代时检测到锁释放")}),i()}function testImportAttributes(){return _testImportAttributes.apply(this,arguments)}function _testImportAttributes(){return _testImportAttributes=_asyncToGenerator(_regenerator().m(function o(){var n,e,i,r,t;return _regenerator().w(function(a){for(;;)switch(a.n){case 0:return n=createSuite("Import Attributes (ES2026)"),e=n.test,i=n.assert,r=n.getResults,t=function(){try{return new Function("import('data:text/javascript,export default 1', { with: { type: 'javascript' } })"),!0}catch{return!1}}(),e("动态 import() 支持 with 选项对象",_asyncToGenerator(_regenerator().m(function s(){var u,c,l;return _regenerator().w(function(f){for(;;)switch(f.p=f.n){case 0:if(t){f.n=1;break}return i(!0,"(跳过:环境不支持 import with 语法)"),f.a(2);case 1:return u=null,f.p=2,c=new Function('return import("data:text/javascript,export default \\"hello\\"", { with: { type: "javascript" } })'),f.n=3,c();case 3:l=f.v,u=l.default,f.n=5;break;case 4:f.p=4,f.v,u="syntax-ok";case 5:i(u==="hello"||u==="syntax-ok","import with 语法应被环境支持");case 6:return f.a(2)}},s,null,[[2,4]])}))),e("import with 选项中 type 属性为字符串",function(){var s={with:{type:"json"}};i(typeof s.with.type=="string","type 属性应为字符串"),i(s.with.type==="json","json type 应正确设置")}),e("import() 的第二个参数结构",function(){var s=[{with:{type:"json"}},{with:{type:"css"}},{with:{type:"javascript"}}];s.forEach(function(u){i(u.with!==void 0,"options.with 应存在"),i(typeof u.with.type=="string","type 应为字符串")}),i(!0,"import() 选项结构验证通过")}),e("JSON 模块导入属性防止 MIME 混淆(原理说明)",function(){var s=!0;i(s,'JSON 模块导入应声明 type: "json" 防止 MIME 混淆攻击')}),e("import with 仅传递元信息,不影响模块标识符",function(){var s="./data.json",u={with:{type:"json"}},c={with:{type:"json"}};i(s==="./data.json","模块说明符不应被 with 属性修改"),i(u.with.type===c.with.type,"相同 type 的 options 应等价")}),a.a(2,r())}},o)})),_testImportAttributes.apply(this,arguments)}var suites2015=[{name:"let & const",fn:testLetConst},{name:"箭头函数",fn:testArrowFunctions},{name:"模板字符串",fn:testTemplateLiterals},{name:"解构赋值",fn:testDestructuring},{name:"默认参数 / Rest / Spread",fn:testDefaultRestSpread},{name:"类(Class)",fn:testClasses},{name:"Promise & async/await",fn:testPromises},{name:"Symbol",fn:testSymbols},{name:"迭代器与生成器",fn:testIteratorsGenerators},{name:"Map & Set & WeakMap & WeakSet",fn:testMapSet},{name:"Proxy & Reflect",fn:testProxyReflect},{name:"增强对象字面量",fn:testEnhancedObjects},{name:"新增内置方法",fn:testNewMethods},{name:"模块(Modules)",fn:testModules},{name:"进制字面量与 Unicode",fn:testBinaryOctalUnicode},{name:"for...of",fn:testForOf},{name:"Map getOrInsert",fn:testMapGetOrInsert}],suites2022=[{name:"Class Fields(私有字段 / 静态字段)",fn:testClassFields},{name:"Class Static Blocks",fn:testClassStaticBlocks},{name:"Array / String .at()",fn:testAtMethod},{name:"Object.hasOwn()",fn:testObjectHasOwn},{name:"Error Cause",fn:testErrorCause},{name:"RegExp /d flag(匹配索引)",fn:testRegExpDFlag},{name:"Top-level await",fn:testTopLevelAwait}],suites2025=[{name:"Iterator Helpers",fn:testIteratorHelpers},{name:"New Set Methods",fn:testSetMethods},{name:"Promise.try",fn:testPromiseTry},{name:"RegExp Duplicate Named Capture Groups",fn:testRegExpDuplicateGroups},{name:"Uint8Array Base64 / Hex",fn:testUint8ArrayBase64Hex},{name:"JSON.parse Source Text Access",fn:testJsonParseSource},{name:"Error.isError",fn:testErrorIsError},{name:"Float16Array",fn:testFloat16Array}],suites2026=[{name:"Math.sumPrecise()",fn:testMathSumPrecise},{name:"RegExp.escape()",fn:testRegExpEscape},{name:"Explicit Resource Management",fn:testExplicitResourceManagement},{name:"Atomics.pause()",fn:testAtomicsPause},{name:"Import Attributes",fn:testImportAttributes}];function runSuites(o){return _runSuites.apply(this,arguments)}function _runSuites(){return _runSuites=_asyncToGenerator(_regenerator().m(function o(n){var e,i,r,t,a,s;return _regenerator().w(function(u){for(;;)switch(u.p=u.n){case 0:e=[],i=_createForOfIteratorHelper(n),u.p=1,i.s();case 2:if((r=i.n()).done){u.n=5;break}return t=r.value,u.n=3,t.fn();case 3:a=u.v,e.push.apply(e,_toConsumableArray(a));case 4:u.n=2;break;case 5:u.n=7;break;case 6:u.p=6,s=u.v,i.e(s);case 7:return u.p=7,i.f(),u.f(7);case 8:return u.a(2,e)}},o,null,[[1,6,7,8]])})),_runSuites.apply(this,arguments)}function runAll2015(){return _runAll.apply(this,arguments)}function _runAll(){return _runAll=_asyncToGenerator(_regenerator().m(function o(){return _regenerator().w(function(n){for(;;)switch(n.n){case 0:return n.a(2,runSuites(suites2015))}},o)})),_runAll.apply(this,arguments)}function runAll2022(){return _runAll2.apply(this,arguments)}function _runAll2(){return _runAll2=_asyncToGenerator(_regenerator().m(function o(){return _regenerator().w(function(n){for(;;)switch(n.n){case 0:return n.a(2,runSuites(suites2022))}},o)})),_runAll2.apply(this,arguments)}function runAll2025(){return _runAll3.apply(this,arguments)}function _runAll3(){return _runAll3=_asyncToGenerator(_regenerator().m(function o(){return _regenerator().w(function(n){for(;;)switch(n.n){case 0:return n.a(2,runSuites(suites2025))}},o)})),_runAll3.apply(this,arguments)}function runAll2026(){return _runAll4.apply(this,arguments)}function _runAll4(){return _runAll4=_asyncToGenerator(_regenerator().m(function o(){return _regenerator().w(function(n){for(;;)switch(n.n){case 0:return n.a(2,runSuites(suites2026))}},o)})),_runAll4.apply(this,arguments)}function runAll(){return _runAll5.apply(this,arguments)}function _runAll5(){return _runAll5=_asyncToGenerator(_regenerator().m(function o(){return _regenerator().w(function(n){for(;;)switch(n.n){case 0:return n.a(2,runSuites([].concat(suites2015,suites2022,suites2025,suites2026)))}},o)})),_runAll5.apply(this,arguments)}function runAndPrint(){return _runAndPrint.apply(this,arguments)}function _runAndPrint(){return _runAndPrint=_asyncToGenerator(_regenerator().m(function o(){var n,e,i,r,t,a;return _regenerator().w(function(s){for(;;)switch(s.n){case 0:n=0,e=[["ES2015",runAll2015],["ES2022",runAll2022],["ES2025",runAll2025],["ES2026",runAll2026]];case 1:if(!(n<e.length)){s.n=4;break}return i=_slicedToArray(e[n],2),r=i[0],t=i[1],console.log(`
|
|
44
44
|
=== `.concat(r,` 特性测试 ===
|
|
45
|
-
`)),a=printResults,s.n=2,t();case 2:a(s.v);case 3:n++,s.n=1;break;case 4:return s.a(2)}},o)})),_runAndPrint.apply(this,arguments)}
|
|
45
|
+
`)),a=printResults,s.n=2,t();case 2:a(s.v);case 3:n++,s.n=1;break;case 4:return s.a(2)}},o)})),_runAndPrint.apply(this,arguments)}return exports.runAll=runAll,exports.runAll2015=runAll2015,exports.runAll2022=runAll2022,exports.runAll2025=runAll2025,exports.runAll2026=runAll2026,exports.runAndPrint=runAndPrint,exports.testArrowFunctions=testArrowFunctions,exports.testAtMethod=testAtMethod,exports.testAtomicsPause=testAtomicsPause,exports.testBinaryOctalUnicode=testBinaryOctalUnicode,exports.testClassFields=testClassFields,exports.testClassStaticBlocks=testClassStaticBlocks,exports.testClasses=testClasses,exports.testDefaultRestSpread=testDefaultRestSpread,exports.testDestructuring=testDestructuring,exports.testEnhancedObjects=testEnhancedObjects,exports.testErrorCause=testErrorCause,exports.testErrorIsError=testErrorIsError,exports.testExplicitResourceManagement=testExplicitResourceManagement,exports.testFloat16Array=testFloat16Array,exports.testForOf=testForOf,exports.testImportAttributes=testImportAttributes,exports.testIteratorHelpers=testIteratorHelpers,exports.testIteratorsGenerators=testIteratorsGenerators,exports.testJsonParseSource=testJsonParseSource,exports.testLetConst=testLetConst,exports.testMapGetOrInsert=testMapGetOrInsert,exports.testMapSet=testMapSet,exports.testMathSumPrecise=testMathSumPrecise,exports.testModules=testModules,exports.testNewMethods=testNewMethods,exports.testObjectHasOwn=testObjectHasOwn,exports.testPromiseTry=testPromiseTry,exports.testPromises=testPromises,exports.testProxyReflect=testProxyReflect,exports.testRegExpDFlag=testRegExpDFlag,exports.testRegExpDuplicateGroups=testRegExpDuplicateGroups,exports.testRegExpEscape=testRegExpEscape,exports.testSetMethods=testSetMethods,exports.testSymbols=testSymbols,exports.testTemplateLiterals=testTemplateLiterals,exports.testTopLevelAwait=testTopLevelAwait,exports.testUint8ArrayBase64Hex=testUint8ArrayBase64Hex,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports}({});
|
package/dist/esfeatures.js
CHANGED
|
@@ -3435,27 +3435,27 @@ function _testImportAttributes() {
|
|
|
3435
3435
|
return !1;
|
|
3436
3436
|
}
|
|
3437
3437
|
}(), e("动态 import() 支持 with 选项对象", /* @__PURE__ */ _asyncToGenerator(/* @__PURE__ */ _regenerator().m(function s() {
|
|
3438
|
-
var u, c;
|
|
3439
|
-
return _regenerator().w(function(
|
|
3438
|
+
var u, c, l;
|
|
3439
|
+
return _regenerator().w(function(f) {
|
|
3440
3440
|
for (; ; )
|
|
3441
|
-
switch (
|
|
3441
|
+
switch (f.p = f.n) {
|
|
3442
3442
|
case 0:
|
|
3443
3443
|
if (t) {
|
|
3444
|
-
|
|
3444
|
+
f.n = 1;
|
|
3445
3445
|
break;
|
|
3446
3446
|
}
|
|
3447
|
-
return i(!0, "(跳过:环境不支持 import with 语法)"),
|
|
3447
|
+
return i(!0, "(跳过:环境不支持 import with 语法)"), f.a(2);
|
|
3448
3448
|
case 1:
|
|
3449
|
-
return u = null,
|
|
3449
|
+
return u = null, f.p = 2, c = new Function('return import("data:text/javascript,export default \\"hello\\"", { with: { type: "javascript" } })'), f.n = 3, c();
|
|
3450
3450
|
case 3:
|
|
3451
|
-
|
|
3451
|
+
l = f.v, u = l.default, f.n = 5;
|
|
3452
3452
|
break;
|
|
3453
3453
|
case 4:
|
|
3454
|
-
|
|
3454
|
+
f.p = 4, f.v, u = "syntax-ok";
|
|
3455
3455
|
case 5:
|
|
3456
3456
|
i(u === "hello" || u === "syntax-ok", "import with 语法应被环境支持");
|
|
3457
3457
|
case 6:
|
|
3458
|
-
return
|
|
3458
|
+
return f.a(2);
|
|
3459
3459
|
}
|
|
3460
3460
|
}, s, null, [[2, 4]]);
|
|
3461
3461
|
}))), e("import with 选项中 type 属性为字符串", function() {
|
package/dist/esfeatures.umd.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function(o,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(o=typeof globalThis<"u"?globalThis:o||self,n(o.EsFeatures={}))})(this,function(exports){"use strict";var _documentCurrentScript=typeof document<"u"?document.currentScript:null;function _arrayLikeToArray(o,n){(n==null||n>o.length)&&(n=o.length);for(var e=0,i=Array(n);e<n;e++)i[e]=o[e];return i}function _arrayWithHoles(o){if(Array.isArray(o))return o}function _arrayWithoutHoles(o){if(Array.isArray(o))return _arrayLikeToArray(o)}function _assertClassBrand(o,n,e){if(typeof o=="function"?o===n:o.has(n))return arguments.length<3?n:e;throw new TypeError("Private element is not present on this object")}function _assertThisInitialized(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}function asyncGeneratorStep(o,n,e,i,r,t,a){try{var s=o[t](a),u=s.value}catch(c){return void e(c)}s.done?n(u):Promise.resolve(u).then(i,r)}function _asyncToGenerator(o){return function(){var n=this,e=arguments;return new Promise(function(i,r){var t=o.apply(n,e);function a(u){asyncGeneratorStep(t,i,r,a,s,"next",u)}function s(u){asyncGeneratorStep(t,i,r,a,s,"throw",u)}a(void 0)})}}function _callSuper(o,n,e){return n=_getPrototypeOf(n),_possibleConstructorReturn(o,_isNativeReflectConstruct()?Reflect.construct(n,e||[],_getPrototypeOf(o).constructor):n.apply(o,e))}function _checkInRHS(o){if(Object(o)!==o)throw TypeError("right-hand side of 'in' should be an object, got "+(o!==null?typeof o:"null"));return o}function _checkPrivateRedeclaration(o,n){if(n.has(o))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classCallCheck(o,n){if(!(o instanceof n))throw new TypeError("Cannot call a class as a function")}function _classPrivateFieldGet2(o,n){return o.get(_assertClassBrand(o,n))}function _classPrivateFieldInitSpec(o,n,e){_checkPrivateRedeclaration(o,n),n.set(o,e)}function _classPrivateFieldSet2(o,n,e){return o.set(_assertClassBrand(o,n),e),e}function _classPrivateMethodInitSpec(o,n){_checkPrivateRedeclaration(o,n),n.add(o)}function _construct(o,n,e){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,n);var r=new(o.bind.apply(o,i));return e&&_setPrototypeOf(r,e.prototype),r}function _defineProperties(o,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(o,_toPropertyKey(i.key),i)}}function _createClass(o,n,e){return n&&_defineProperties(o.prototype,n),e&&_defineProperties(o,e),Object.defineProperty(o,"prototype",{writable:!1}),o}function _createForOfIteratorHelper(o,n){var e=typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(!e){if(Array.isArray(o)||(e=_unsupportedIterableToArray(o))||n&&o&&typeof o.length=="number"){e&&(o=e);var i=0,r=function(){};return{s:r,n:function(){return i>=o.length?{done:!0}:{done:!1,value:o[i++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var t,a=!0,s=!1;return{s:function(){e=e.call(o)},n:function(){var u=e.next();return a=u.done,u},e:function(u){s=!0,t=u},f:function(){try{a||e.return==null||e.return()}finally{if(s)throw t}}}}function _defineProperty(o,n,e){return(n=_toPropertyKey(n))in o?Object.defineProperty(o,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):o[n]=e,o}function _get(){return _get=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(o,n,e){var i=_superPropBase(o,n);if(i){var r=Object.getOwnPropertyDescriptor(i,n);return r.get?r.get.call(arguments.length<3?o:e):r.value}},_get.apply(null,arguments)}function _getPrototypeOf(o){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},_getPrototypeOf(o)}function _inherits(o,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");o.prototype=Object.create(n&&n.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),Object.defineProperty(o,"prototype",{writable:!1}),n&&_setPrototypeOf(o,n)}function _isNativeFunction(o){try{return Function.toString.call(o).indexOf("[native code]")!==-1}catch{return typeof o=="function"}}function _isNativeReflectConstruct(){try{var o=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(_isNativeReflectConstruct=function(){return!!o})()}function _iterableToArray(o){if(typeof Symbol<"u"&&o[Symbol.iterator]!=null||o["@@iterator"]!=null)return Array.from(o)}function _iterableToArrayLimit(o,n){var e=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(e!=null){var i,r,t,a,s=[],u=!0,c=!1;try{if(t=(e=e.call(o)).next,n===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(i=t.call(e)).done)&&(s.push(i.value),s.length!==n);u=!0);}catch(l){c=!0,r=l}finally{try{if(!u&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw r}}return s}}function _nonIterableRest(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _nonIterableSpread(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
4
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ownKeys(o,n){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(o);n&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(o,r).enumerable})),e.push.apply(e,i)}return e}function _objectSpread2(o){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?ownKeys(Object(e),!0).forEach(function(i){_defineProperty(o,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(e)):ownKeys(Object(e)).forEach(function(i){Object.defineProperty(o,i,Object.getOwnPropertyDescriptor(e,i))})}return o}function _objectWithoutProperties(o,n){if(o==null)return{};var e,i,r=_objectWithoutPropertiesLoose(o,n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);for(i=0;i<t.length;i++)e=t[i],n.indexOf(e)===-1&&{}.propertyIsEnumerable.call(o,e)&&(r[e]=o[e])}return r}function _objectWithoutPropertiesLoose(o,n){if(o==null)return{};var e={};for(var i in o)if({}.hasOwnProperty.call(o,i)){if(n.indexOf(i)!==-1)continue;e[i]=o[i]}return e}function _possibleConstructorReturn(o,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(o)}function _regenerator(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var o,n,e=typeof Symbol=="function"?Symbol:{},i=e.iterator||"@@iterator",r=e.toStringTag||"@@toStringTag";function t(y,p,S,M){var I=p&&p.prototype instanceof s?p:s,R=Object.create(I.prototype);return _regeneratorDefine(R,"_invoke",function(F,T,N){var
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ownKeys(o,n){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(o);n&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(o,r).enumerable})),e.push.apply(e,i)}return e}function _objectSpread2(o){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?ownKeys(Object(e),!0).forEach(function(i){_defineProperty(o,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(e)):ownKeys(Object(e)).forEach(function(i){Object.defineProperty(o,i,Object.getOwnPropertyDescriptor(e,i))})}return o}function _objectWithoutProperties(o,n){if(o==null)return{};var e,i,r=_objectWithoutPropertiesLoose(o,n);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);for(i=0;i<t.length;i++)e=t[i],n.indexOf(e)===-1&&{}.propertyIsEnumerable.call(o,e)&&(r[e]=o[e])}return r}function _objectWithoutPropertiesLoose(o,n){if(o==null)return{};var e={};for(var i in o)if({}.hasOwnProperty.call(o,i)){if(n.indexOf(i)!==-1)continue;e[i]=o[i]}return e}function _possibleConstructorReturn(o,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(o)}function _regenerator(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var o,n,e=typeof Symbol=="function"?Symbol:{},i=e.iterator||"@@iterator",r=e.toStringTag||"@@toStringTag";function t(y,p,S,M){var I=p&&p.prototype instanceof s?p:s,R=Object.create(I.prototype);return _regeneratorDefine(R,"_invoke",function(F,T,N){var _,h,v,P=0,k=N||[],A=!1,w={p:0,n:0,v:o,a:O,f:O.bind(o,4),d:function(b,m){return _=b,h=0,v=o,w.n=m,a}};function O(b,m){for(h=b,v=m,n=0;!A&&P&&!E&&n<k.length;n++){var E,g=k[n],j=w.p,C=g[2];b>3?(E=C===m)&&(v=g[(h=g[4])?5:(h=3,3)],g[4]=g[5]=o):g[0]<=j&&((E=b<2&&j<g[1])?(h=0,w.v=m,w.n=g[1]):j<C&&(E=b<3||g[0]>m||m>C)&&(g[4]=b,g[5]=m,w.n=C,h=0))}if(E||b>1)return a;throw A=!0,m}return function(b,m,E){if(P>1)throw TypeError("Generator is already running");for(A&&m===1&&O(m,E),h=m,v=E;(n=h<2?o:v)||!A;){_||(h?h<3?(h>1&&(w.n=-1),O(h,v)):w.n=v:w.v=v);try{if(P=2,_){if(h||(b="next"),n=_[b]){if(!(n=n.call(_,v)))throw TypeError("iterator result is not an object");if(!n.done)return n;v=n.value,h<2&&(h=0)}else h===1&&(n=_.return)&&n.call(_),h<2&&(v=TypeError("The iterator does not provide a '"+b+"' method"),h=1);_=o}else if((n=(A=w.n<0)?v:F.call(T,w))!==a)break}catch(g){_=o,h=1,v=g}finally{P=1}}return{value:n,done:A}}}(y,S,M),!0),R}var a={};function s(){}function u(){}function c(){}n=Object.getPrototypeOf;var l=[][i]?n(n([][i]())):(_regeneratorDefine(n={},i,function(){return this}),n),f=c.prototype=s.prototype=Object.create(l);function d(y){return Object.setPrototypeOf?Object.setPrototypeOf(y,c):(y.__proto__=c,_regeneratorDefine(y,r,"GeneratorFunction")),y.prototype=Object.create(f),y}return u.prototype=c,_regeneratorDefine(f,"constructor",c),_regeneratorDefine(c,"constructor",u),u.displayName="GeneratorFunction",_regeneratorDefine(c,r,"GeneratorFunction"),_regeneratorDefine(f),_regeneratorDefine(f,r,"Generator"),_regeneratorDefine(f,i,function(){return this}),_regeneratorDefine(f,"toString",function(){return"[object Generator]"}),(_regenerator=function(){return{w:t,m:d}})()}function _regeneratorDefine(o,n,e,i){var r=Object.defineProperty;try{r({},"",{})}catch{r=0}_regeneratorDefine=function(t,a,s,u){function c(l,f){_regeneratorDefine(t,l,function(d){return this._invoke(l,f,d)})}a?r?r(t,a,{value:s,enumerable:!u,configurable:!u,writable:!u}):t[a]=s:(c("next",0),c("throw",1),c("return",2))},_regeneratorDefine(o,n,e,i)}function _regeneratorValues(o){if(o!=null){var n=o[typeof Symbol=="function"&&Symbol.iterator||"@@iterator"],e=0;if(n)return n.call(o);if(typeof o.next=="function")return o;if(!isNaN(o.length))return{next:function(){return o&&e>=o.length&&(o=void 0),{value:o&&o[e++],done:!o}}}}throw new TypeError(typeof o+" is not iterable")}function _setPrototypeOf(o,n){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,i){return e.__proto__=i,e},_setPrototypeOf(o,n)}function _slicedToArray(o,n){return _arrayWithHoles(o)||_iterableToArrayLimit(o,n)||_unsupportedIterableToArray(o,n)||_nonIterableRest()}function _superPropBase(o,n){for(;!{}.hasOwnProperty.call(o,n)&&(o=_getPrototypeOf(o))!==null;);return o}function _superPropGet(o,n,e,i){var r=_get(_getPrototypeOf(1&i?o.prototype:o),n,e);return 2&i&&typeof r=="function"?function(t){return r.apply(e,t)}:r}function _taggedTemplateLiteral(o,n){return n||(n=o.slice(0)),Object.freeze(Object.defineProperties(o,{raw:{value:Object.freeze(n)}}))}function _toConsumableArray(o){return _arrayWithoutHoles(o)||_iterableToArray(o)||_unsupportedIterableToArray(o)||_nonIterableSpread()}function _toPrimitive(o,n){if(typeof o!="object"||!o)return o;var e=o[Symbol.toPrimitive];if(e!==void 0){var i=e.call(o,n||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(o)}function _toPropertyKey(o){var n=_toPrimitive(o,"string");return typeof n=="symbol"?n:n+""}function _typeof(o){"@babel/helpers - typeof";return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},_typeof(o)}function _unsupportedIterableToArray(o,n){if(o){if(typeof o=="string")return _arrayLikeToArray(o,n);var e={}.toString.call(o).slice(8,-1);return e==="Object"&&o.constructor&&(e=o.constructor.name),e==="Map"||e==="Set"?Array.from(o):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?_arrayLikeToArray(o,n):void 0}}function _wrapNativeSuper(o){var n=typeof Map=="function"?new Map:void 0;return _wrapNativeSuper=function(e){if(e===null||!_isNativeFunction(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(n!==void 0){if(n.has(e))return n.get(e);n.set(e,i)}function i(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(i,e)},_wrapNativeSuper(o)}function _wrapRegExp(){_wrapRegExp=function(r,t){return new e(r,void 0,t)};var o=RegExp.prototype,n=new WeakMap;function e(r,t,a){var s=RegExp(r,t);return n.set(s,a||n.get(r)),_setPrototypeOf(s,e.prototype)}function i(r,t){var a=n.get(t);return Object.keys(a).reduce(function(s,u){var c=a[u];if(typeof c=="number")s[u]=r[c];else{for(var l=0;r[c[l]]===void 0&&l+1<c.length;)l++;s[u]=r[c[l]]}return s},Object.create(null))}return _inherits(e,RegExp),e.prototype.exec=function(r){var t=o.exec.call(this,r);if(t){t.groups=i(t,this);var a=t.indices;a&&(a.groups=i(a,this))}return t},e.prototype[Symbol.replace]=function(r,t){if(typeof t=="string"){var a=n.get(this);return o[Symbol.replace].call(this,r,t.replace(/\$<([^>]+)(>|$)/g,function(u,c,l){if(l==="")return u;var f=a[c];return Array.isArray(f)?"$"+f.join("$"):typeof f=="number"?"$"+f:""}))}if(typeof t=="function"){var s=this;return o[Symbol.replace].call(this,r,function(){var u=arguments;return typeof u[u.length-1]!="object"&&(u=[].slice.call(u)).push(i(u,s)),t.apply(this,u)})}return o[Symbol.replace].call(this,r,t)},_wrapRegExp.apply(this,arguments)}function createSuite(o){var n=[];function e(t,a){try{var s=a();if(s instanceof Promise)return s.then(function(){n.push({suite:o,case:t,status:"pass"})}).catch(function(u){n.push({suite:o,case:t,status:"fail",error:u.message})});n.push({suite:o,case:t,status:"pass"})}catch(u){n.push({suite:o,case:t,status:"fail",error:u.message})}}function i(t,a){if(!t)throw new Error(a||"断言失败")}function r(){return n}return{test:e,assert:i,getResults:r}}function printResults(o){var n=0,e=0;o.forEach(function(i){i.status==="pass"?(n++,console.log(" ✓ [".concat(i.suite,"] ").concat(i.case))):(e++,console.error(" ✗ [".concat(i.suite,"] ").concat(i.case," — ").concat(i.error)))}),console.log(`
|
|
5
5
|
共 `.concat(o.length," 项,通过 ").concat(n,",失败 ").concat(e))}function testLetConst(){var o=createSuite("let & const"),n=o.test,e=o.assert,i=o.getResults;return n("let 块级作用域",function(){for(var r=[],t=0;t<3;t++)r.push(t);e(r[0]===0&&r[2]===2,"let 循环变量应为独立值")}),n("let 不可重复声明",function(){try{new Function('"use strict"; let x = 1; let x = 2;')(),e(!1,"应抛出 SyntaxError")}catch(r){e(r instanceof SyntaxError||r instanceof TypeError,"应为语法错误")}}),n("let 暂时性死区(TDZ)",function(){try{new Function('"use strict"; console.log(y); let y = 1;')(),e(!1,"应抛出 ReferenceError")}catch{e(!0)}}),n("const 声明常量",function(){var r=3.14159;e(r===3.14159,"const 值应保持不变")}),n("const 不可重新赋值",function(){try{new Function('"use strict"; const x = 1; x = 2;')(),e(!1,"应抛出 TypeError")}catch(r){e(r instanceof TypeError,"应为 TypeError")}}),n("const 对象属性可修改",function(){var r={a:1};r.a=2,e(r.a===2,"const 对象的属性可以修改")}),i()}function testArrowFunctions(){var o=createSuite("箭头函数"),n=o.test,e=o.assert,i=o.getResults;return n("基本语法",function(){var r=function(a,s){return a+s};e(r(2,3)===5,"箭头函数返回值应为 5")}),n("单参数省略括号",function(){var r=function(a){return a*2};e(r(4)===8,"单参数箭头函数应正常工作")}),n("无参数需要括号",function(){var r=function(){return"hello"};e(r()==="hello","无参数箭头函数应正常工作")}),n("多行函数体需要花括号和 return",function(){var r=function(a,s){var u=a+s;return u*2};e(r(2,3)===10,"多行箭头函数应正确计算")}),n("返回对象字面量需要括号",function(){var r=function(s){return{value:s}},t=r(42);e(t.value===42,"箭头函数返回对象应正确包裹")}),n("this 词法绑定",function(){function r(){var a=this;this.count=0;var s=function(){a.count++};s(),s()}var t=new r;e(t.count===2,"箭头函数 this 应绑定外层作用域")}),n("没有 arguments 对象",function(){e(!0,"箭头函数无独立 arguments")}),n("不能用作构造函数(原生环境)",function(){var r=function(){},t=r.prototype===void 0;if(t)try{new r,e(!1,"应抛出 TypeError")}catch(a){e(a instanceof TypeError,"箭头函数不能 new")}}),i()}var _templateObject,_templateObject2;function testTemplateLiterals(){var o=createSuite("模板字符串"),n=o.test,e=o.assert,i=o.getResults;return n("基本插值",function(){var r="ES2015",t="Hello, ".concat(r,"!");e(t==="Hello, ES2015!","模板字符串插值应正确")}),n("表达式插值",function(){var r=3,t=4,a="".concat(r," + ").concat(t," = ").concat(r+t);e(a==="3 + 4 = 7","模板字符串支持表达式")}),n("多行字符串",function(){var r=`第一行
|
|
6
6
|
第二行`;e(r.includes(`
|
|
7
7
|
`),"模板字符串支持多行")}),n("嵌套模板",function(){var r=["a","b","c"],t="items: ".concat(r.map(function(a){return"[".concat(a,"]")}).join(", "));e(t==="items: [a], [b], [c]","模板字符串可以嵌套")}),n("标签模板 - 基本用法",function(){function r(s){for(var u=arguments.length,c=new Array(u>1?u-1:0),l=1;l<u;l++)c[l-1]=arguments[l];return s.raw[0]+c[0].toUpperCase()}var t="world",a=r(_templateObject||(_templateObject=_taggedTemplateLiteral(["hello ",""])),t);e(a==="hello WORLD","标签模板应正确处理")}),n("标签模板 - String.raw",function(){var r=String.raw(_templateObject2||(_templateObject2=_taggedTemplateLiteral([`C:Users est
|
|
@@ -40,6 +40,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
40
40
|
}
|
|
41
41
|
log.push('after-block')
|
|
42
42
|
})()
|
|
43
|
-
`),l.n=2,c(u,Symbol);case 2:i(u[0]==="in-block","异步块内应正常执行"),i(u[1]==="async-disposed","await using 应等待异步 dispose 完成"),i(u[2]==="after-block","dispose 之后才继续执行块后代码");case 3:return l.a(2)}},s)}))),e("DisposableStack —— 手动管理资源栈",function(){if(typeof DisposableStack>"u"){i(!0,"(跳过:环境不支持 DisposableStack)");return}var s=[],u=new DisposableStack;u.defer(function(){return s.push("deferred-1")}),u.defer(function(){return s.push("deferred-2")}),u.dispose(),i(s.join(",")==="deferred-2,deferred-1","DisposableStack 应按 LIFO 执行")}),a.a(2,r())}},o)})),_testExplicitResourceManagement.apply(this,arguments)}function testAtomicsPause(){var o=createSuite("Atomics.pause() (ES2026)"),n=o.test,e=o.assert,i=o.getResults,r=typeof Atomics.pause=="function";return n("Atomics.pause 函数存在",function(){if(!r){e(!0,"(跳过:环境不支持 Atomics.pause)");return}e(typeof Atomics.pause=="function","Atomics.pause 应为函数")}),n("无参数调用不抛出错误",function(){if(!r){e(!0,"(跳过)");return}var t=!1;try{Atomics.pause()}catch{t=!0}e(!t,"Atomics.pause() 无参数调用不应抛出")}),n("传入整数参数不抛出错误",function(){if(!r){e(!0,"(跳过)");return}var t=!1;try{Atomics.pause(0),Atomics.pause(1),Atomics.pause(100)}catch{t=!0}e(!t,"Atomics.pause(N) 应接受非负整数参数")}),n("返回值为 undefined",function(){if(!r){e(!0,"(跳过)");return}e(Atomics.pause()===void 0,"Atomics.pause() 应返回 undefined")}),n("自旋等待模式下连续调用不崩溃",function(){if(!r){e(!0,"(跳过)");return}for(var t=0;t<10;t++)Atomics.pause(t);e(t===10,"10 次自旋循环应正常完成")}),n("与 SharedArrayBuffer + Atomics.load 配合(模拟场景)",function(){if(!r){e(!0,"(跳过)");return}if(typeof SharedArrayBuffer>"u"){e(!0,"(跳过:环境不支持 SharedArrayBuffer)");return}var t=new SharedArrayBuffer(4),a=new Int32Array(t);a[0]=1;for(var s=0,u=5;Atomics.load(a,0)!==0&&s<u;)Atomics.pause(s),s++,s===3&&Atomics.store(a,0,0);e(Atomics.load(a,0)===0,"自旋等待后标志位应变为 0(锁释放)"),e(s===3,"应在第 3 次迭代时检测到锁释放")}),i()}function testImportAttributes(){return _testImportAttributes.apply(this,arguments)}function _testImportAttributes(){return _testImportAttributes=_asyncToGenerator(_regenerator().m(function o(){var n,e,i,r,t;return _regenerator().w(function(a){for(;;)switch(a.n){case 0:return n=createSuite("Import Attributes (ES2026)"),e=n.test,i=n.assert,r=n.getResults,t=function(){try{return new Function("import('data:text/javascript,export default 1', { with: { type: 'javascript' } })"),!0}catch{return!1}}(),e("动态 import() 支持 with 选项对象",_asyncToGenerator(_regenerator().m(function s(){var u,c;return _regenerator().w(function(
|
|
43
|
+
`),l.n=2,c(u,Symbol);case 2:i(u[0]==="in-block","异步块内应正常执行"),i(u[1]==="async-disposed","await using 应等待异步 dispose 完成"),i(u[2]==="after-block","dispose 之后才继续执行块后代码");case 3:return l.a(2)}},s)}))),e("DisposableStack —— 手动管理资源栈",function(){if(typeof DisposableStack>"u"){i(!0,"(跳过:环境不支持 DisposableStack)");return}var s=[],u=new DisposableStack;u.defer(function(){return s.push("deferred-1")}),u.defer(function(){return s.push("deferred-2")}),u.dispose(),i(s.join(",")==="deferred-2,deferred-1","DisposableStack 应按 LIFO 执行")}),a.a(2,r())}},o)})),_testExplicitResourceManagement.apply(this,arguments)}function testAtomicsPause(){var o=createSuite("Atomics.pause() (ES2026)"),n=o.test,e=o.assert,i=o.getResults,r=typeof Atomics.pause=="function";return n("Atomics.pause 函数存在",function(){if(!r){e(!0,"(跳过:环境不支持 Atomics.pause)");return}e(typeof Atomics.pause=="function","Atomics.pause 应为函数")}),n("无参数调用不抛出错误",function(){if(!r){e(!0,"(跳过)");return}var t=!1;try{Atomics.pause()}catch{t=!0}e(!t,"Atomics.pause() 无参数调用不应抛出")}),n("传入整数参数不抛出错误",function(){if(!r){e(!0,"(跳过)");return}var t=!1;try{Atomics.pause(0),Atomics.pause(1),Atomics.pause(100)}catch{t=!0}e(!t,"Atomics.pause(N) 应接受非负整数参数")}),n("返回值为 undefined",function(){if(!r){e(!0,"(跳过)");return}e(Atomics.pause()===void 0,"Atomics.pause() 应返回 undefined")}),n("自旋等待模式下连续调用不崩溃",function(){if(!r){e(!0,"(跳过)");return}for(var t=0;t<10;t++)Atomics.pause(t);e(t===10,"10 次自旋循环应正常完成")}),n("与 SharedArrayBuffer + Atomics.load 配合(模拟场景)",function(){if(!r){e(!0,"(跳过)");return}if(typeof SharedArrayBuffer>"u"){e(!0,"(跳过:环境不支持 SharedArrayBuffer)");return}var t=new SharedArrayBuffer(4),a=new Int32Array(t);a[0]=1;for(var s=0,u=5;Atomics.load(a,0)!==0&&s<u;)Atomics.pause(s),s++,s===3&&Atomics.store(a,0,0);e(Atomics.load(a,0)===0,"自旋等待后标志位应变为 0(锁释放)"),e(s===3,"应在第 3 次迭代时检测到锁释放")}),i()}function testImportAttributes(){return _testImportAttributes.apply(this,arguments)}function _testImportAttributes(){return _testImportAttributes=_asyncToGenerator(_regenerator().m(function o(){var n,e,i,r,t;return _regenerator().w(function(a){for(;;)switch(a.n){case 0:return n=createSuite("Import Attributes (ES2026)"),e=n.test,i=n.assert,r=n.getResults,t=function(){try{return new Function("import('data:text/javascript,export default 1', { with: { type: 'javascript' } })"),!0}catch{return!1}}(),e("动态 import() 支持 with 选项对象",_asyncToGenerator(_regenerator().m(function s(){var u,c,l;return _regenerator().w(function(f){for(;;)switch(f.p=f.n){case 0:if(t){f.n=1;break}return i(!0,"(跳过:环境不支持 import with 语法)"),f.a(2);case 1:return u=null,f.p=2,c=new Function('return import("data:text/javascript,export default \\"hello\\"", { with: { type: "javascript" } })'),f.n=3,c();case 3:l=f.v,u=l.default,f.n=5;break;case 4:f.p=4,f.v,u="syntax-ok";case 5:i(u==="hello"||u==="syntax-ok","import with 语法应被环境支持");case 6:return f.a(2)}},s,null,[[2,4]])}))),e("import with 选项中 type 属性为字符串",function(){var s={with:{type:"json"}};i(typeof s.with.type=="string","type 属性应为字符串"),i(s.with.type==="json","json type 应正确设置")}),e("import() 的第二个参数结构",function(){var s=[{with:{type:"json"}},{with:{type:"css"}},{with:{type:"javascript"}}];s.forEach(function(u){i(u.with!==void 0,"options.with 应存在"),i(typeof u.with.type=="string","type 应为字符串")}),i(!0,"import() 选项结构验证通过")}),e("JSON 模块导入属性防止 MIME 混淆(原理说明)",function(){var s=!0;i(s,'JSON 模块导入应声明 type: "json" 防止 MIME 混淆攻击')}),e("import with 仅传递元信息,不影响模块标识符",function(){var s="./data.json",u={with:{type:"json"}},c={with:{type:"json"}};i(s==="./data.json","模块说明符不应被 with 属性修改"),i(u.with.type===c.with.type,"相同 type 的 options 应等价")}),a.a(2,r())}},o)})),_testImportAttributes.apply(this,arguments)}var suites2015=[{name:"let & const",fn:testLetConst},{name:"箭头函数",fn:testArrowFunctions},{name:"模板字符串",fn:testTemplateLiterals},{name:"解构赋值",fn:testDestructuring},{name:"默认参数 / Rest / Spread",fn:testDefaultRestSpread},{name:"类(Class)",fn:testClasses},{name:"Promise & async/await",fn:testPromises},{name:"Symbol",fn:testSymbols},{name:"迭代器与生成器",fn:testIteratorsGenerators},{name:"Map & Set & WeakMap & WeakSet",fn:testMapSet},{name:"Proxy & Reflect",fn:testProxyReflect},{name:"增强对象字面量",fn:testEnhancedObjects},{name:"新增内置方法",fn:testNewMethods},{name:"模块(Modules)",fn:testModules},{name:"进制字面量与 Unicode",fn:testBinaryOctalUnicode},{name:"for...of",fn:testForOf},{name:"Map getOrInsert",fn:testMapGetOrInsert}],suites2022=[{name:"Class Fields(私有字段 / 静态字段)",fn:testClassFields},{name:"Class Static Blocks",fn:testClassStaticBlocks},{name:"Array / String .at()",fn:testAtMethod},{name:"Object.hasOwn()",fn:testObjectHasOwn},{name:"Error Cause",fn:testErrorCause},{name:"RegExp /d flag(匹配索引)",fn:testRegExpDFlag},{name:"Top-level await",fn:testTopLevelAwait}],suites2025=[{name:"Iterator Helpers",fn:testIteratorHelpers},{name:"New Set Methods",fn:testSetMethods},{name:"Promise.try",fn:testPromiseTry},{name:"RegExp Duplicate Named Capture Groups",fn:testRegExpDuplicateGroups},{name:"Uint8Array Base64 / Hex",fn:testUint8ArrayBase64Hex},{name:"JSON.parse Source Text Access",fn:testJsonParseSource},{name:"Error.isError",fn:testErrorIsError},{name:"Float16Array",fn:testFloat16Array}],suites2026=[{name:"Math.sumPrecise()",fn:testMathSumPrecise},{name:"RegExp.escape()",fn:testRegExpEscape},{name:"Explicit Resource Management",fn:testExplicitResourceManagement},{name:"Atomics.pause()",fn:testAtomicsPause},{name:"Import Attributes",fn:testImportAttributes}];function runSuites(o){return _runSuites.apply(this,arguments)}function _runSuites(){return _runSuites=_asyncToGenerator(_regenerator().m(function o(n){var e,i,r,t,a,s;return _regenerator().w(function(u){for(;;)switch(u.p=u.n){case 0:e=[],i=_createForOfIteratorHelper(n),u.p=1,i.s();case 2:if((r=i.n()).done){u.n=5;break}return t=r.value,u.n=3,t.fn();case 3:a=u.v,e.push.apply(e,_toConsumableArray(a));case 4:u.n=2;break;case 5:u.n=7;break;case 6:u.p=6,s=u.v,i.e(s);case 7:return u.p=7,i.f(),u.f(7);case 8:return u.a(2,e)}},o,null,[[1,6,7,8]])})),_runSuites.apply(this,arguments)}function runAll2015(){return _runAll.apply(this,arguments)}function _runAll(){return _runAll=_asyncToGenerator(_regenerator().m(function o(){return _regenerator().w(function(n){for(;;)switch(n.n){case 0:return n.a(2,runSuites(suites2015))}},o)})),_runAll.apply(this,arguments)}function runAll2022(){return _runAll2.apply(this,arguments)}function _runAll2(){return _runAll2=_asyncToGenerator(_regenerator().m(function o(){return _regenerator().w(function(n){for(;;)switch(n.n){case 0:return n.a(2,runSuites(suites2022))}},o)})),_runAll2.apply(this,arguments)}function runAll2025(){return _runAll3.apply(this,arguments)}function _runAll3(){return _runAll3=_asyncToGenerator(_regenerator().m(function o(){return _regenerator().w(function(n){for(;;)switch(n.n){case 0:return n.a(2,runSuites(suites2025))}},o)})),_runAll3.apply(this,arguments)}function runAll2026(){return _runAll4.apply(this,arguments)}function _runAll4(){return _runAll4=_asyncToGenerator(_regenerator().m(function o(){return _regenerator().w(function(n){for(;;)switch(n.n){case 0:return n.a(2,runSuites(suites2026))}},o)})),_runAll4.apply(this,arguments)}function runAll(){return _runAll5.apply(this,arguments)}function _runAll5(){return _runAll5=_asyncToGenerator(_regenerator().m(function o(){return _regenerator().w(function(n){for(;;)switch(n.n){case 0:return n.a(2,runSuites([].concat(suites2015,suites2022,suites2025,suites2026)))}},o)})),_runAll5.apply(this,arguments)}function runAndPrint(){return _runAndPrint.apply(this,arguments)}function _runAndPrint(){return _runAndPrint=_asyncToGenerator(_regenerator().m(function o(){var n,e,i,r,t,a;return _regenerator().w(function(s){for(;;)switch(s.n){case 0:n=0,e=[["ES2015",runAll2015],["ES2022",runAll2022],["ES2025",runAll2025],["ES2026",runAll2026]];case 1:if(!(n<e.length)){s.n=4;break}return i=_slicedToArray(e[n],2),r=i[0],t=i[1],console.log(`
|
|
44
44
|
=== `.concat(r,` 特性测试 ===
|
|
45
|
-
`)),a=printResults,s.n=2,t();case 2:a(s.v);case 3:n++,s.n=1;break;case 4:return s.a(2)}},o)})),_runAndPrint.apply(this,arguments)}
|
|
45
|
+
`)),a=printResults,s.n=2,t();case 2:a(s.v);case 3:n++,s.n=1;break;case 4:return s.a(2)}},o)})),_runAndPrint.apply(this,arguments)}exports.runAll=runAll,exports.runAll2015=runAll2015,exports.runAll2022=runAll2022,exports.runAll2025=runAll2025,exports.runAll2026=runAll2026,exports.runAndPrint=runAndPrint,exports.testArrowFunctions=testArrowFunctions,exports.testAtMethod=testAtMethod,exports.testAtomicsPause=testAtomicsPause,exports.testBinaryOctalUnicode=testBinaryOctalUnicode,exports.testClassFields=testClassFields,exports.testClassStaticBlocks=testClassStaticBlocks,exports.testClasses=testClasses,exports.testDefaultRestSpread=testDefaultRestSpread,exports.testDestructuring=testDestructuring,exports.testEnhancedObjects=testEnhancedObjects,exports.testErrorCause=testErrorCause,exports.testErrorIsError=testErrorIsError,exports.testExplicitResourceManagement=testExplicitResourceManagement,exports.testFloat16Array=testFloat16Array,exports.testForOf=testForOf,exports.testImportAttributes=testImportAttributes,exports.testIteratorHelpers=testIteratorHelpers,exports.testIteratorsGenerators=testIteratorsGenerators,exports.testJsonParseSource=testJsonParseSource,exports.testLetConst=testLetConst,exports.testMapGetOrInsert=testMapGetOrInsert,exports.testMapSet=testMapSet,exports.testMathSumPrecise=testMathSumPrecise,exports.testModules=testModules,exports.testNewMethods=testNewMethods,exports.testObjectHasOwn=testObjectHasOwn,exports.testPromiseTry=testPromiseTry,exports.testPromises=testPromises,exports.testProxyReflect=testProxyReflect,exports.testRegExpDFlag=testRegExpDFlag,exports.testRegExpDuplicateGroups=testRegExpDuplicateGroups,exports.testRegExpEscape=testRegExpEscape,exports.testSetMethods=testSetMethods,exports.testSymbols=testSymbols,exports.testTemplateLiterals=testTemplateLiterals,exports.testTopLevelAwait=testTopLevelAwait,exports.testUint8ArrayBase64Hex=testUint8ArrayBase64Hex,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|