Skip to content

Commit 51bf17d

Browse files
committed
use 'to' prefix for method names
tc39/proposal-change-array-by-copy#50
1 parent 034feb9 commit 51bf17d

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

src/Float16Array.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ export class Float16Array {
525525
return convertToNumber(float16bitsArray[k]);
526526
}
527527

528-
/** @see https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.withAt */
529-
withAt(index, value) {
528+
/** @see https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.with */
529+
with(index, value) {
530530
assertFloat16Array(this);
531531
const float16bitsArray = getFloat16BitsArray(this);
532532

@@ -871,8 +871,8 @@ export class Float16Array {
871871
return this;
872872
}
873873

874-
/** @see https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.withReversed */
875-
withReversed() {
874+
/** @see https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toReversed */
875+
toReversed() {
876876
assertFloat16Array(this);
877877
const float16bitsArray = getFloat16BitsArray(this);
878878

@@ -931,8 +931,8 @@ export class Float16Array {
931931
return this;
932932
}
933933

934-
/** @see https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.withSorted */
935-
withSorted(...opts) {
934+
/** @see https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toSorted */
935+
toSorted(...opts) {
936936
assertFloat16Array(this);
937937
const float16bitsArray = getFloat16BitsArray(this);
938938

@@ -1023,8 +1023,8 @@ export class Float16Array {
10231023
return /** @type {any} */ (array);
10241024
}
10251025

1026-
/** @see https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.withSpliced */
1027-
withSpliced(...opts) {
1026+
/** @see https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toSpliced */
1027+
toSpliced(...opts) {
10281028
assertFloat16Array(this);
10291029
const float16bitsArray = getFloat16BitsArray(this);
10301030

test/Float16Array.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -826,30 +826,30 @@ describe("Float16Array", () => {
826826
});
827827
});
828828

829-
describe("#withAt()", () => {
830-
it("property `name` is 'withAt'", () => {
831-
assert(Float16Array.prototype.withAt.name === "withAt");
829+
describe("#with()", () => {
830+
it("property `name` is 'with'", () => {
831+
assert(Float16Array.prototype.with.name === "with");
832832
});
833833

834834
it("property `length` is 1", () => {
835-
assert(Float16Array.prototype.withAt.length === 2);
835+
assert(Float16Array.prototype.with.length === 2);
836836
});
837837

838-
it("withAt", () => {
838+
it("with", () => {
839839
const float16_1 = new Float16Array([1, 2, 3]);
840-
const float16_2 = float16_1.withAt(1, 4);
840+
const float16_2 = float16_1.with(1, 4);
841841

842842
assert(float16_1.buffer !== float16_2.buffer);
843843
assert.equalFloat16ArrayValues(float16_1, [1, 2, 3]);
844844
assert.equalFloat16ArrayValues(float16_2, [1, 4, 3]);
845845

846-
const float16_3 = float16_1.withAt(-1, 4);
846+
const float16_3 = float16_1.with(-1, 4);
847847

848848
assert(float16_1.buffer !== float16_3.buffer);
849849
assert.equalFloat16ArrayValues(float16_1, [1, 2, 3]);
850850
assert.equalFloat16ArrayValues(float16_3, [1, 2, 4]);
851851

852-
const float16_4 = float16_1.withAt(0, "aaa");
852+
const float16_4 = float16_1.with(0, "aaa");
853853

854854
assert(float16_1.buffer !== float16_4.buffer);
855855
assert.equalFloat16ArrayValues(float16_1, [1, 2, 3]);
@@ -861,20 +861,20 @@ describe("Float16Array", () => {
861861

862862
// out of range
863863
assert.throws(() => {
864-
float16.withAt(5, 0);
864+
float16.with(5, 0);
865865
}, RangeError);
866866
assert.throws(() => {
867-
float16.withAt(-5, 0);
867+
float16.with(-5, 0);
868868
}, RangeError);
869869

870870
assert.throws(() => {
871-
float16.withAt(Symbol(), 0);
871+
float16.with(Symbol(), 0);
872872
}, TypeError);
873873

874874
// Safari 13 doesn't have BigInt
875875
if (typeof BigInt !== "undefined") {
876876
assert.throws(() => {
877-
float16.withAt(BigInt(0), 0);
877+
float16.with(BigInt(0), 0);
878878
}, TypeError);
879879
}
880880
});
@@ -1490,18 +1490,18 @@ describe("Float16Array", () => {
14901490
});
14911491
});
14921492

1493-
describe("#withReversed()", () => {
1493+
describe("#toReversed()", () => {
14941494
it("property `name` is 'reverse'", () => {
1495-
assert(Float16Array.prototype.withReversed.name === "withReversed");
1495+
assert(Float16Array.prototype.toReversed.name === "toReversed");
14961496
});
14971497

14981498
it("property `length` is 0", () => {
1499-
assert(Float16Array.prototype.withReversed.length === 0);
1499+
assert(Float16Array.prototype.toReversed.length === 0);
15001500
});
15011501

1502-
it("withReversed", () => {
1502+
it("toReversed", () => {
15031503
const float16_1 = new Float16Array([1, 2, 3]);
1504-
const float16_2 = float16_1.withReversed();
1504+
const float16_2 = float16_1.toReversed();
15051505

15061506
assert(float16_1.buffer !== float16_2.buffer);
15071507
assert.equalFloat16ArrayValues(float16_1, [1, 2, 3]);
@@ -1611,13 +1611,13 @@ describe("Float16Array", () => {
16111611
});
16121612
});
16131613

1614-
describe("#withSorted()", () => {
1615-
it("property `name` is 'withSorted'", () => {
1616-
assert(Float16Array.prototype.withSorted.name === "withSorted");
1614+
describe("#toSorted()", () => {
1615+
it("property `name` is 'toSorted'", () => {
1616+
assert(Float16Array.prototype.toSorted.name === "toSorted");
16171617
});
16181618

16191619
it("property `length` is 0", () => {
1620-
assert(Float16Array.prototype.withSorted.length === 0);
1620+
assert(Float16Array.prototype.toSorted.length === 0);
16211621
});
16221622

16231623
it("check default compare", () => {
@@ -1632,7 +1632,7 @@ describe("Float16Array", () => {
16321632
Infinity,
16331633
-Infinity,
16341634
]);
1635-
const float16_2 = float16_1.withSorted();
1635+
const float16_2 = float16_1.toSorted();
16361636

16371637
assert(float16_1.buffer !== float16_2.buffer);
16381638
assert.equalFloat16ArrayValues(float16_1, [
@@ -1661,7 +1661,7 @@ describe("Float16Array", () => {
16611661

16621662
it("check custom compare", () => {
16631663
const float16_1 = new Float16Array([1, 2, -1, -2, Infinity, -Infinity]);
1664-
const float16_2 = float16_1.withSorted((x, y) => y - x);
1664+
const float16_2 = float16_1.toSorted((x, y) => y - x);
16651665

16661666
assert(float16_1.buffer !== float16_2.buffer);
16671667
assert.equalFloat16ArrayValues(float16_1, [
@@ -1809,43 +1809,43 @@ describe("Float16Array", () => {
18091809
});
18101810
});
18111811

1812-
describe("#withSpliced()", () => {
1813-
it("property `name` is 'withSpliced'", () => {
1814-
assert(Float16Array.prototype.withSpliced.name === "withSpliced");
1812+
describe("#toSpliced()", () => {
1813+
it("property `name` is 'toSpliced'", () => {
1814+
assert(Float16Array.prototype.toSpliced.name === "toSpliced");
18151815
});
18161816

18171817
it("property `length` is 0", () => {
1818-
assert(Float16Array.prototype.withSpliced.length === 0);
1818+
assert(Float16Array.prototype.toSpliced.length === 0);
18191819
});
18201820

18211821
it("get spliced Array", () => {
18221822
const float16_1 = new Float16Array([1, 2, 3]);
1823-
const float16_2 = float16_1.withSpliced();
1823+
const float16_2 = float16_1.toSpliced();
18241824

18251825
assert(float16_1.buffer !== float16_2.buffer);
18261826
assert.equalFloat16ArrayValues(float16_1, float16_2);
18271827

1828-
const float16_3 = float16_1.withSpliced(1);
1828+
const float16_3 = float16_1.toSpliced(1);
18291829

18301830
assert(float16_1.buffer !== float16_3.buffer);
18311831
assert.equalFloat16ArrayValues(float16_3, [1]);
18321832

1833-
const float16_4 = float16_1.withSpliced(1, -1);
1833+
const float16_4 = float16_1.toSpliced(1, -1);
18341834

18351835
assert(float16_1.buffer !== float16_4.buffer);
18361836
assert.equalFloat16ArrayValues(float16_4, [1, 2, 3]);
18371837

1838-
const float16_5 = float16_1.withSpliced(1, 10);
1838+
const float16_5 = float16_1.toSpliced(1, 10);
18391839

18401840
assert(float16_1.buffer !== float16_5.buffer);
18411841
assert.equalFloat16ArrayValues(float16_5, [1]);
18421842

1843-
const float16_6 = float16_1.withSpliced(1, 1);
1843+
const float16_6 = float16_1.toSpliced(1, 1);
18441844

18451845
assert(float16_1.buffer !== float16_6.buffer);
18461846
assert.equalFloat16ArrayValues(float16_6, [1, 3]);
18471847

1848-
const float16_7 = float16_1.withSpliced(1, 1, 5, 6);
1848+
const float16_7 = float16_1.toSpliced(1, 1, 5, 6);
18491849

18501850
assert(float16_1.buffer !== float16_7.buffer);
18511851
assert.equalFloat16ArrayValues(float16_7, [1, 5, 6, 3]);

0 commit comments

Comments
 (0)