Twitter hashtag: #esspec
自己紹介 (近況報告)
syumai
GoとTSやってます
最近tRPCとPrismaを初めて(若干だけ)触りました
tRPCはなかなか面白かったです
TypeScriptの型情報をサーバー・クライアント間で使い回せる
型はzodのschemaで書く
実際には、サーバーからはJSON.stringifyした値を送っているだけで、クライアントは型付きのAPI clientを使用してJSONに型を付けている
今週末Go Con mini Sendaiと言うイベントで仙台に行きます
Jun Yasumura / harupiyo Jun Yasumura.icon
本なので索引も作れる
tars0x9752 (たーず / naoki aoyama) tars0x9752.icon
10月から 働き始めた
aumyさんとエンカウント
noyannoyan.icon
三連休はReactのScheduler実装を読んでいた
Schedulerはレンダリングのpriority queueみたいなイメージ
JSConfになにか出せればいいな、という気持ちを持ち続けたい
お仕事はチームメンバーが増えて、入った順で先に数えたほうがはやくなってしまった
yebis0942yebis0942.icon
部屋にカーテンを引いています
GPUアクセラレーションを有効にしてたらOSがクラッシュする
無効にしてたらGoogle meetの背景ぼかしが使えない
tars0x9752.icon Google meet の背景ぼかし、便利だけど地味に制約多いのがつらいという意味で共感
TOOD: Webカメラのマイクはなんとかして無効にする設定にする(デバイスを強制的に認識させないようにする方法ありそう)
前回のあらすじ
ToUint8Clamp
これだけ Round half to even
UInt8ClampedArray でしか使われてない
ToBigInt
Number は ToBigInt の前で弾かれる想定
StringIntegerLiteral
[~Sep] なんだっけ → Sepパターンを除くの意味っぽい
inclusive interval → 閉区間
ToString
yebis0942.icon(あらすじ説明助かる… :pray:)
ToObject
argument をテーブル16に従って object に変換する
Boolean objects
Number objects
String objects
Symbol objects
BigInt objects
BigIntはprivitiveだっけ?→privitiveでした
member of one of the types Undefined, Null, Boolean, Number, BigInt, Symbol, or String as defined in clause 6
ToObjectはどこで使われるのか?
GetValue()とかObjectのメソッドとかで呼ばれている
abstract operationの中では基本的にToObjectされているような感じがする
ToObjectの実行結果をECMAScriptから確認するには?
Object関数を使うのがよさそう
Object([value])という表記の意味
optionalなvalueという引数を1つ取るという意味?
abstract operationのAlgorithm Conventionsではそういう意味になりそう
Optional parameters are denoted with surrounding brackets ([ , name ])
ToPropertyKey
ToPrimitive(argument, string)がsymbolを返すのはどんな場合?
argumentがsymbolである場合
@@toPrimitiveメソッドがsymbolを返す場合
! はabrupt completionをかえさず、value filedがかならずあることを示す
Similarly, prefix ! is used to indicate that the following invocation of an abstract or syntax-directed operation will never return an abrupt completion and that the resulting Completion Record's Value field should be used in place of the return value of the operation.
ToLength
suitable for use as the length of an array-like object
具体的にはどんな値なのか
algorithm stepでは0 <= n <= 2^53 - 1にclampしている
Number.MAX_SAFE_INTEGER == 2**53-1
"integer index"の範囲内にしていると解釈してもいいような気もするyebis0942.icon
An integer index is a String-valued property key that is a canonical numeric string and whose numeric value is either +0𝔽 or a positive integral Number ≤ 𝔽(2^53 - 1). An array index is an integer index whose numeric value i is in the range +0𝔽 ≤ i < 𝔽(2^32 - 1).
An array-like object is any object for which this operation returns a normal completion.
LengthOfArrayLikeに成功するならarray-like objectである
Arrays and String objects are examples of array-like objects.
(英語)clamp: 数値をある範囲に収めること
CanonicalNumericIndexString
canonical 正規の、正統な など
1. If argument is "-0", return -0𝔽.
-0 をtoStringすると "0" になってしまうため、sameValueで同値にならないので、stepを明示的に分けているように見える
code:js
a"constructor" // canonical numeric stringではないのでOrdinalGetが実行されてconstructorが取れる a'-0' // canonicalなはずなのに、なぜかundefined // '-0'をキーとしたプロパティが生える
code:js
0 === -0 // true
Object.is(0, -0) // false (Object.isはSameValueを使っている)
NOTE: 配列と負数インデックス
RubyやPythonではarray[-n]とすると「末尾から数えてn番目」の要素にアクセスできる
ECMAScriptでもArray.prototype.atで同様のことができる
ToIndex
値が数値型に変換でき、変換した値がインデックスとして使える範囲内にあれば、変換した値を返す
使われている場所
new ArrayBuffer(length)のlengthの処理
code:js
new ArrayBuffer(Number.MAX_SAFE_INTEGER+1) // RangeError: ToIndexによるエラー
new ArrayBuffer(Number.MAX_SAFE_INTEGER) // RangeError: メモリの確保できないエラー
7.2 Testing and Comparison Operations
RequireObjectCoercible
Undefined と null は TypeError
それ以外は Return argument
argument を ToObject できるかどうかを判定するやつ
CreateHTMLとは
HTMLタグを生成するString.prototype配下のメソッドで使われている
code:js
"google".big() // <big>google</big>
"google".sup() // 下付き文字
"google".marquee() // ありそうでない
IsArray
If argument is an Array exotic object, return true.
Array Exotic Objectsかどうかはどうやって判定するのか?
An object is an Array exotic object (or simply, an Array) if its [[DefineOwnProperty]] internal method uses the following implementation, and its other essential internal methods use the definitions found in 10.1.
If argument is a Proxy exotic object, then...
proxyの元にあるオブジェクトに対してIsArrayを呼ぶ
code:js
array = []
proxy = new Proxy(array, { get: () => 1 })
Array.isArray(proxy) // true
notArray = {}
proxy = new Proxy(notArray, { get: () => 1 })
Array.isArray(proxy) // false
IsCallable
internal method [[Call]] をもっていて、呼び出し可能な関数であるということを判定する
Array.prototype.find のような、callbackを受け取る系の操作で使われる
IsConstructor
internal method [[Construct]] をもった function object であることを判定する
[[Construct]] の存在確認しかしてない
[[Construct]]があるオブジェクトには[[Call]]もあるというルールがある
IsExtensible
追加的なプロパティを O に追加できるかを判定
throw されることがありうる(oridnaryなら大丈夫っぽい)
たとえばProxyされたオブジェクトが不変条件に反する動作をすると処理系が強制的にTypeErrorを送出する
Object.isExtensible で直接呼べる
In ECMAScript 2015, if the argument to Object.isExtensible is not an object it is treated as if it was a non-extensible ordinary object with no own properties. In the previous edition, a non-object argument always causes a TypeError to be thrown.
むかしはObject.isExtensibleも非objectをわたすとthrowしていたのかnoyan.icon
こういう非互換な変更も入るんですねーyebis0942.icon
IsIntegralNumber
有限な整数の値かどうかを判定
floor(abs(...))の話は過去回参照
この辺のやつで使える
Number.isInteger
Number.isSafeInteger
IsPropertyKey
String or Symbolであるときだけtrueを返す
Q. numberはproperty keyには使えない?
A. String または Symbolのみが使えます
A property key value is either an ECMAScript String value or a Symbol value.
IsRegExp
RegExp Prototype Object
@@matchの使い方
String.prototype.matchの動作に影響を与えることができる
※String.prototype.matchAllに対応するのは@@matchAll
yebis0942.icon@@matchAllだけが生えていてもIsRegExpはfalseなのか…
残された謎
どういう経緯で導入されたのか?
どんなときに便利なのか?