当前位置: 首页 > 科技观察

第92届TC39会议召开,这些提案取得新进展!

时间:2023-03-21 15:16:55 科技观察

大家好,我叫CUGGZ。TC39是一个促进JavaScript发展的技术委员会。它由各个主流浏览器厂商的代表组成。它的主要工作是制定ECMAScript标准。TC39每两个月举行一次面对面会议。9月13日至16日举行的第92届TC39会议在以下提案上取得了新进展:第3阶段:Array.fromAsync。Stage2:Well-FormedUnicodeStrings,关于确定字符串是否为格式良好的Unicode的方法的提案。第一阶段:提取器,ECMAScript提取器。对于提案,从提案到最终纳入ECMAScript标准分为五个步骤:stage0(稻草人):TC39的任何成员都可以提交。stage1(proposal):进入这个阶段意味着提案被认为是正式的,需要详细描述提案的场景和API。stage2(草案):如果进化到这个阶段的提案最终能够进入标准,那么后续阶段不会有太大变化,因为理论上只接受增量修改。state3(candidate):这个阶段的proposals只有在遇到重大问题时才会修改,需要完整完成specificationdocument。state4(finished):这个阶段的提案会被纳入ES每年发布的规范中。1.Array.fromAsync在JavaScript中有一个内置的Array.from方法,用于从类数组或可迭代对象生成新的数组实例。ECMAScript2018中引入了异步可迭代对象。而JavaScript一直缺乏一种内置方法来直接从异步可迭代对象生成数组。proposal-array-from-async提案中提出的Array.fromAsync方法就是为了解决这个问题而提出的。我们来看一个简单的例子:asyncfunction*asyncGen(n){for(leti=0;ivalueinstanceofTemporal.Instant?{matched:true,value:[value]}:valueinstanceofDate?{matched:true,value:[Temporal.Instant.fromEpochMilliseconds(value.getTime())]}:typeofvalue==="string"?{matched:true,value:[Temporal.Instant.from(value)]}:{matched:false};}};classBook{constructor({isbn,title,createdAt:InstantExtractor(createdAt)=Temporal.Now.instant(),modifiedAt:InstantExtractor(modifiedAt)=createdAt}){this.isbn=isbn;this.title=标题;this.createdAt=createdAt;this.modifiedAt=modifiedAt;}}newBook({isbn:"...",title:"...",createdAt:Temporal.Instant.from("...")});newBook({isbn:"...",title:"...",createdAt:newDate()});newBook({isbn:"...",title:"...",createdAt:"..."});提交地址:https://github.com/tc39/proposal-extractors。相关链接:[1]isWellFormed()和toWellFormed():https://tc39.es/proposal-is-usv-string/。[2]模式匹配提案:https://github.com/tc39/proposal-pattern-matching。