From 22642eafb6c268c8348bd68c8569a30918b66d6b Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Mon, 1 Jul 2024 21:39:30 +0200 Subject: [PATCH 01/11] Optimize compare and equal functions (#238) * Optimize compare and equal functions * Changelog * Add tests --- CHANGELOG.md | 2 ++ src/Core__Date.mjs | 4 ++-- src/Core__Float.mjs | 16 ---------------- src/Core__Float.res | 5 ++--- src/Core__Float.resi | 4 ++-- src/Core__Int.mjs | 16 ---------------- src/Core__Int.res | 5 ++--- src/Core__Int.resi | 4 ++-- src/Core__String.mjs | 16 ---------------- src/Core__String.res | 5 ++--- src/Core__String.resi | 4 ++-- test/FloatTests.mjs | 10 ++++++++++ test/FloatTests.res | 2 ++ test/IntTests.mjs | 10 ++++++++++ test/IntTests.res | 2 ++ test/StringTests.mjs | 21 +++++++++++++++++++++ test/StringTests.res | 5 +++++ 17 files changed, 66 insertions(+), 65 deletions(-) create mode 100644 test/StringTests.mjs create mode 100644 test/StringTests.res diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b4deda7..222470b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next version +- Optimize compare and equal functions. https://github.com/rescript-association/rescript-core/pull/238 + ## 1.5.2 - Remove aliases for runtime modules (`MapperRt`, `Internal`) and `Re`. https://github.com/rescript-association/rescript-core/pull/237 diff --git a/src/Core__Date.mjs b/src/Core__Date.mjs index bb84ed38..38e6e98f 100644 --- a/src/Core__Date.mjs +++ b/src/Core__Date.mjs @@ -1,6 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Core__Float from "./Core__Float.mjs"; +import * as Caml from "rescript/lib/es6/caml.js"; var UTC = {}; @@ -9,7 +9,7 @@ function equal(a, b) { } function compare(a, b) { - return Core__Float.compare(a.getTime(), b.getTime()); + return Caml.float_compare(a.getTime(), b.getTime()); } export { diff --git a/src/Core__Float.mjs b/src/Core__Float.mjs index 44a3d032..9fb41d4c 100644 --- a/src/Core__Float.mjs +++ b/src/Core__Float.mjs @@ -3,20 +3,6 @@ var Constants = {}; -function equal(a, b) { - return a === b; -} - -function compare(a, b) { - if (a < b) { - return -1; - } else if (a > b) { - return 1; - } else { - return 0; - } -} - function fromString(i) { var i$1 = parseFloat(i); if (isNaN(i$1)) { @@ -37,8 +23,6 @@ function clamp(min, max, value) { export { Constants , - equal , - compare , fromString , clamp , } diff --git a/src/Core__Float.res b/src/Core__Float.res index ada4de71..c701db92 100644 --- a/src/Core__Float.res +++ b/src/Core__Float.res @@ -7,10 +7,9 @@ module Constants = { @val external maxValue: float = "Number.MAX_VALUE" } -let equal = (a: float, b: float) => a === b +external equal: (float, float) => bool = "%equal" -let compare = (a: float, b: float) => - a < b ? Core__Ordering.less : a > b ? Core__Ordering.greater : Core__Ordering.equal +external compare: (float, float) => Core__Ordering.t = "%compare" @val external isNaN: float => bool = "isNaN" @val external isFinite: float => bool = "isFinite" diff --git a/src/Core__Float.resi b/src/Core__Float.resi index 9609147e..806d8df9 100644 --- a/src/Core__Float.resi +++ b/src/Core__Float.resi @@ -109,9 +109,9 @@ module Constants: { external maxValue: float = "Number.MAX_VALUE" } -let equal: (float, float) => bool +external equal: (float, float) => bool = "%equal" -let compare: (float, float) => Core__Ordering.t +external compare: (float, float) => Core__Ordering.t = "%compare" /** `isNaN(v)` tests if the given `v` is `NaN`. diff --git a/src/Core__Int.mjs b/src/Core__Int.mjs index 96f246a0..7900b26f 100644 --- a/src/Core__Int.mjs +++ b/src/Core__Int.mjs @@ -2,20 +2,6 @@ import * as Core__Array from "./Core__Array.mjs"; -function equal(a, b) { - return a === b; -} - -function compare(a, b) { - if (a < b) { - return -1; - } else if (a > b) { - return 1; - } else { - return 0; - } -} - function fromString(x, radix) { var maybeInt = radix !== undefined ? parseInt(x, radix) : parseInt(x); if (isNaN(maybeInt) || maybeInt > 2147483647 || maybeInt < -2147483648) { @@ -85,8 +71,6 @@ var Constants = { export { Constants , - equal , - compare , fromString , range , rangeWithOptions , diff --git a/src/Core__Int.res b/src/Core__Int.res index 94d57c62..b1a0f22e 100644 --- a/src/Core__Int.res +++ b/src/Core__Int.res @@ -3,10 +3,9 @@ module Constants = { @inline let maxValue = 2147483647 } -let equal = (a: int, b: int) => a === b +external equal: (int, int) => bool = "%equal" -let compare = (a: int, b: int) => - a < b ? Core__Ordering.less : a > b ? Core__Ordering.greater : Core__Ordering.equal +external compare: (int, int) => Core__Ordering.t = "%compare" @send external toExponential: (int, ~digits: int=?) => string = "toExponential" @deprecated("Use `toExponential` instead") @send diff --git a/src/Core__Int.resi b/src/Core__Int.resi index 37c44ac3..bb74f75a 100644 --- a/src/Core__Int.resi +++ b/src/Core__Int.resi @@ -56,9 +56,9 @@ module Constants: { let maxValue: int } -let equal: (int, int) => bool +external equal: (int, int) => bool = "%equal" -let compare: (int, int) => Core__Ordering.t +external compare: (int, int) => Core__Ordering.t = "%compare" /** `toExponential(n, ~digits=?)` return a `string` representing the given value in diff --git a/src/Core__String.mjs b/src/Core__String.mjs index c6f60393..1b8a0b9f 100644 --- a/src/Core__String.mjs +++ b/src/Core__String.mjs @@ -1,20 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -function equal(a, b) { - return a === b; -} - -function compare(a, b) { - if (a < b) { - return -1; - } else if (a > b) { - return 1; - } else { - return 0; - } -} - function indexOfOpt(s, search) { var index = s.indexOf(search); if (index !== -1) { @@ -40,8 +26,6 @@ function searchOpt(s, re) { } export { - equal , - compare , indexOfOpt , lastIndexOfOpt , searchOpt , diff --git a/src/Core__String.res b/src/Core__String.res index 22db37b5..392c3165 100644 --- a/src/Core__String.res +++ b/src/Core__String.res @@ -6,10 +6,9 @@ @val external fromCodePoint: int => string = "String.fromCodePoint" @variadic @val external fromCodePointMany: array => string = "String.fromCodePoint" -let equal = (a: string, b: string) => a === b +external equal: (string, string) => bool = "%equal" -let compare = (a: string, b: string) => - a < b ? Core__Ordering.less : a > b ? Core__Ordering.greater : Core__Ordering.equal +external compare: (string, string) => Core__Ordering.t = "%compare" @get external length: string => int = "length" @get_index external get: (string, int) => option = "" diff --git a/src/Core__String.resi b/src/Core__String.resi index b3e429ba..99e5b6df 100644 --- a/src/Core__String.resi +++ b/src/Core__String.resi @@ -118,9 +118,9 @@ String.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺` @val external fromCodePointMany: array => string = "String.fromCodePoint" -let equal: (string, string) => bool +external equal: (string, string) => bool = "%equal" -let compare: (string, string) => Core__Ordering.t +external compare: (string, string) => Core__Ordering.t = "%compare" /** `length(str)` returns the length of the given `string`. diff --git a/test/FloatTests.mjs b/test/FloatTests.mjs index 013aaabb..10d8de3a 100644 --- a/test/FloatTests.mjs +++ b/test/FloatTests.mjs @@ -237,6 +237,16 @@ Test.run([ "clamp - min -infinity, max -infinity" ], Core__Float.clamp(PervasivesU.neg_infinity, PervasivesU.neg_infinity, 4.2), eq, PervasivesU.neg_infinity); +Test.run([ + [ + "FloatTests.res", + 49, + 20, + 46 + ], + "Float.equal optimization" + ], false, eq, false); + export { eq , } diff --git a/test/FloatTests.res b/test/FloatTests.res index c9f933ca..8ca2d201 100644 --- a/test/FloatTests.res +++ b/test/FloatTests.res @@ -45,3 +45,5 @@ Test.run( eq, neg_infinity, ) + +Test.run(__POS_OF__("Float.equal optimization"), Float.equal(1., 3.), eq, false) diff --git a/test/IntTests.mjs b/test/IntTests.mjs index 593fb9eb..2ab9a0ce 100644 --- a/test/IntTests.mjs +++ b/test/IntTests.mjs @@ -548,6 +548,16 @@ Test.run([ "clamp - > min, > max" ], Core__Int.clamp(40, 40, 42), eq, 40); +Test.run([ + [ + "IntTests.res", + 170, + 20, + 44 + ], + "Int.equal optimization" + ], false, eq, false); + export { eq , $$catch , diff --git a/test/IntTests.res b/test/IntTests.res index 4535b18e..ebbb7e8c 100644 --- a/test/IntTests.res +++ b/test/IntTests.res @@ -166,3 +166,5 @@ Test.run(__POS_OF__("clamp - < min, < max"), Int.clamp(~min=50, ~max=60, 42), eq Test.run(__POS_OF__("clamp - < min, > max"), Int.clamp(~min=50, ~max=40, 42), eq, 50) // min wins Test.run(__POS_OF__("clamp - > min, < max"), Int.clamp(~min=40, ~max=60, 42), eq, 42) Test.run(__POS_OF__("clamp - > min, > max"), Int.clamp(~min=40, ~max=40, 42), eq, 40) + +Test.run(__POS_OF__("Int.equal optimization"), Int.equal(1, 3), eq, false) diff --git a/test/StringTests.mjs b/test/StringTests.mjs new file mode 100644 index 00000000..9bb62166 --- /dev/null +++ b/test/StringTests.mjs @@ -0,0 +1,21 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Test from "./Test.mjs"; +import * as Caml_obj from "rescript/lib/es6/caml_obj.js"; + +var eq = Caml_obj.equal; + +Test.run([ + [ + "StringTests.res", + 5, + 20, + 47 + ], + "String.equal optimization" + ], false, eq, false); + +export { + eq , +} +/* Not a pure module */ diff --git a/test/StringTests.res b/test/StringTests.res new file mode 100644 index 00000000..a476d408 --- /dev/null +++ b/test/StringTests.res @@ -0,0 +1,5 @@ +open RescriptCore + +let eq = (a, b) => a == b + +Test.run(__POS_OF__("String.equal optimization"), String.equal("one", "three"), eq, false) From ddc4a08051af47761efadd62fdbd4c1d840f8c4c Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Thu, 29 Aug 2024 14:47:48 +0200 Subject: [PATCH 02/11] Add make and convenience functions for async iterators (#243) * add make and convenience functions for async iterators * changelog * fix doc examples --- CHANGELOG.md | 1 + src/Core__AsyncIterator.mjs | 27 ++++++++++++ src/Core__AsyncIterator.res | 19 +++++++++ src/Core__AsyncIterator.resi | 82 +++++++++++++++++++++++++++++++++++- test/IteratorTests.mjs | 38 ++++++++++++++++- test/IteratorTests.res | 25 +++++++++++ test/TestSuite.mjs | 6 +-- 7 files changed, 193 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 222470b5..9b7f3989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Next version - Optimize compare and equal functions. https://github.com/rescript-association/rescript-core/pull/238 +- Add `make` and `done` + `value` functions to `AsyncIterator`. https://github.com/rescript-association/rescript-core/pull/243 ## 1.5.2 diff --git a/src/Core__AsyncIterator.mjs b/src/Core__AsyncIterator.mjs index 9c43464a..240039c8 100644 --- a/src/Core__AsyncIterator.mjs +++ b/src/Core__AsyncIterator.mjs @@ -1,5 +1,20 @@ // Generated by ReScript, PLEASE EDIT WITH CARE +import * as Caml_option from "rescript/lib/es6/caml_option.js"; + +function value(v) { + return { + done: false, + value: Caml_option.some(v) + }; +} + +function done(finalValue) { + return { + done: true, + value: finalValue + }; +} async function forEach(iterator, f) { var iteratorDone = false; @@ -10,7 +25,19 @@ async function forEach(iterator, f) { }; } +var make = (function makeAsyncIterator(next) { + return { + next, + [Symbol.asyncIterator]() { + return this; + } + } +}); + export { + make , + value , + done , forEach , } /* No side effect */ diff --git a/src/Core__AsyncIterator.res b/src/Core__AsyncIterator.res index 4781fbe7..56abad28 100644 --- a/src/Core__AsyncIterator.res +++ b/src/Core__AsyncIterator.res @@ -5,6 +5,16 @@ type value<'a> = { value: option<'a>, } +let value = v => { + done: false, + value: Some(v), +} + +let done = (~finalValue=?) => { + done: true, + value: finalValue, +} + @send external next: t<'a> => promise> = "next" let forEach = async (iterator, f) => { @@ -16,3 +26,12 @@ let forEach = async (iterator, f) => { iteratorDone := done } } + +let make: (unit => promise>) => t<'value> = %raw(`function makeAsyncIterator(next) { + return { + next, + [Symbol.asyncIterator]() { + return this; + } + } +}`) diff --git a/src/Core__AsyncIterator.resi b/src/Core__AsyncIterator.resi index 5644838b..bbe8de3b 100644 --- a/src/Core__AsyncIterator.resi +++ b/src/Core__AsyncIterator.resi @@ -19,6 +19,86 @@ type value<'a> = { value: option<'a>, } +/** + `make(nextFn)` + + Creates an async iterator from a function that returns the next value of the iterator. + + ## Examples + - A simple example, creating an async iterator that returns 1, 2, 3: + ```rescript + let context = ref(0) + + let asyncIterator = AsyncIterator.make(async () => { + let currentValue = context.contents + // Increment current value + context := currentValue + 1 + + { + AsyncIterator.value: Some(currentValue), + done: currentValue >= 3 + } + }) + + // This will log 1, 2, 3 + await asyncIterator->AsyncIterator.forEach(value => + switch value { + | Some(value) => Console.log(value) + | None => () + } + ) + ``` + */ +let make: (unit => promise>) => t<'value> + +/** + `value(value)` + + Shorthand for creating a value object with the provided value, and the `done` property set to false. + + ## Examples + ```rescript + let context = ref(0) + + let asyncIterator = AsyncIterator.make(async () => { + let currentValue = context.contents + // Increment current value + context := currentValue + 1 + + if currentValue >= 3 { + AsyncIterator.done() + } else { + AsyncIterator.value(currentValue) + } + }) + ``` + */ +let value: 'value => value<'value> + +/** + `done(~finalValue=?)` + + Shorthand for creating a value object with the `done` property set to true, and the provided value as the final value, if any. + + ## Examples + ```rescript + let context = ref(0) + + let asyncIterator = AsyncIterator.make(async () => { + let currentValue = context.contents + // Increment current value + context := currentValue + 1 + + if currentValue >= 3 { + AsyncIterator.done() + } else { + AsyncIterator.value(currentValue) + } + }) + ``` + */ +let done: (~finalValue: 'value=?) => value<'value> + /** `next(asyncIterator)` @@ -30,7 +110,7 @@ See [async iterator protocols](https://developer.mozilla.org/en-US/docs/Web/Java - A simple example, getting the next value: ```rescript @val external asyncIterator: AsyncIterator.t = "someAsyncIterator" -let {AsyncIterator.done, value} = await asyncIterator->AsyncIterator.next +let value = await asyncIterator->AsyncIterator.next ``` - Complete example, including looping over all values: diff --git a/test/IteratorTests.mjs b/test/IteratorTests.mjs index 55b008a7..c40b9739 100644 --- a/test/IteratorTests.mjs +++ b/test/IteratorTests.mjs @@ -67,11 +67,47 @@ Test.run([ "Async forEach" ], asyncResult.contents, eq, "second"); +var asyncResult$1 = { + contents: undefined +}; + +var count = { + contents: 0 +}; + +var asyncIterator$1 = Core__AsyncIterator.make(async function () { + var currentCount = count.contents; + count.contents = currentCount + 1 | 0; + if (currentCount === 3) { + return Core__AsyncIterator.done(currentCount); + } else { + return Core__AsyncIterator.value(currentCount); + } + }); + +await Core__AsyncIterator.forEach(asyncIterator$1, (function (v) { + if (v === 3) { + asyncResult$1.contents = "done"; + } else { + console.log("next.."); + } + })); + +Test.run([ + [ + "IteratorTests.res", + 69, + 20, + 54 + ], + "Creating your own async iterator" + ], asyncResult$1.contents, eq, "done"); + export { eq , iterator , syncResult , - asyncIterator , asyncResult , + asyncIterator$1 as asyncIterator, } /* iterator Not a pure module */ diff --git a/test/IteratorTests.res b/test/IteratorTests.res index 29a22eac..902df8ae 100644 --- a/test/IteratorTests.res +++ b/test/IteratorTests.res @@ -42,3 +42,28 @@ await asyncIterator->AsyncIterator.forEach(v => { }) Test.run(__POS_OF__("Async forEach"), asyncResult.contents, eq, Some("second")) + +%%private( + let asyncResult = ref(None) + let count = ref(0) +) + +let asyncIterator = AsyncIterator.make(async () => { + let currentCount = count.contents + count := currentCount + 1 + + if currentCount === 3 { + AsyncIterator.done(~finalValue=currentCount) + } else { + AsyncIterator.value(currentCount) + } +}) + +await asyncIterator->AsyncIterator.forEach(v => { + switch v { + | Some(3) => asyncResult.contents = Some("done") + | _ => Console.log("next..") + } +}) + +Test.run(__POS_OF__("Creating your own async iterator"), asyncResult.contents, eq, Some("done")) diff --git a/test/TestSuite.mjs b/test/TestSuite.mjs index e0ee5b0b..00c9cb7d 100644 --- a/test/TestSuite.mjs +++ b/test/TestSuite.mjs @@ -78,10 +78,10 @@ var iterator = IteratorTests.iterator; var syncResult = IteratorTests.syncResult; -var asyncIterator = IteratorTests.asyncIterator; - var asyncResult = IteratorTests.asyncResult; +var asyncIterator = IteratorTests.asyncIterator; + export { bign , TestError , @@ -115,7 +115,7 @@ export { eq , iterator , syncResult , - asyncIterator , asyncResult , + asyncIterator , } /* IntTests Not a pure module */ From 98eb2e8562e5d3284e76de7e882864d51c029558 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Sun, 8 Sep 2024 21:25:13 +0200 Subject: [PATCH 03/11] Int: Add bitwise functions from Pervasives (#245) * Int: Add bitwise functions from Pervasives * Changelog * Put bitwise functions into their own submodule --- CHANGELOG.md | 1 + src/Core__Int.mjs | 9 ++++++ src/Core__Int.res | 12 +++++++ src/Core__Int.resi | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b7f3989..870278d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Optimize compare and equal functions. https://github.com/rescript-association/rescript-core/pull/238 - Add `make` and `done` + `value` functions to `AsyncIterator`. https://github.com/rescript-association/rescript-core/pull/243 +- Int: Add bitwise functions from Pervasives. https://github.com/rescript-association/rescript-core/pull/245 ## 1.5.2 diff --git a/src/Core__Int.mjs b/src/Core__Int.mjs index 7900b26f..0cf704a2 100644 --- a/src/Core__Int.mjs +++ b/src/Core__Int.mjs @@ -64,6 +64,14 @@ function clamp(min, max, value) { } } +function lnot(x) { + return x ^ -1; +} + +var Bitwise = { + lnot: lnot +}; + var Constants = { minValue: -2147483648, maxValue: 2147483647 @@ -75,5 +83,6 @@ export { range , rangeWithOptions , clamp , + Bitwise , } /* No side effect */ diff --git a/src/Core__Int.res b/src/Core__Int.res index b1a0f22e..462af4a7 100644 --- a/src/Core__Int.res +++ b/src/Core__Int.res @@ -90,3 +90,15 @@ let clamp = (~min=?, ~max=?, value): int => { | _ => value } } + +module Bitwise = { + external land: (int, int) => int = "%andint" + external lor: (int, int) => int = "%orint" + external lxor: (int, int) => int = "%xorint" + + external lsl: (int, int) => int = "%lslint" + external lsr: (int, int) => int = "%lsrint" + external asr: (int, int) => int = "%asrint" + + let lnot = x => lxor(x, -1) +} diff --git a/src/Core__Int.resi b/src/Core__Int.resi index bb74f75a..bab41ce0 100644 --- a/src/Core__Int.resi +++ b/src/Core__Int.resi @@ -387,3 +387,82 @@ Int.clamp(42, ~min=50, ~max=40) == 50 ``` */ let clamp: (~min: int=?, ~max: int=?, int) => int + +module Bitwise: { + /** + `land(n1, n2)` calculates the bitwise logical AND of two integers. + + ## Examples + + ```rescript + Int.Bitwise.land(7, 4) == 4 + ``` + */ + external land: (int, int) => int = "%andint" + + /** + `lor(n1, n2)` calculates the bitwise logical OR of two integers. + + ## Examples + + ```rescript + Int.Bitwise.lor(7, 4) == 7 + ``` + */ + external lor: (int, int) => int = "%orint" + + /** + `lxor(n1, n2)` calculates the bitwise logical XOR of two integers. + + ## Examples + + ```rescript + Int.Bitwise.lxor(7, 4) == 3 + ``` + */ + external lxor: (int, int) => int = "%xorint" + + /** + `lnot(n)` calculates the bitwise logical NOT of an integer. + + ## Examples + + ```rescript + Int.Bitwise.lnot(2) == -3 + ``` + */ + let lnot: int => int + + /** + `lsl(n, length)` calculates the bitwise logical left shift of an integer `n` by `length`. + + ## Examples + + ```rescript + Int.Bitwise.lsl(4, 1) == 8 + ``` + */ + external lsl: (int, int) => int = "%lslint" + + /** + `lsr(n, length)` calculates the bitwise logical right shift of an integer `n` by `length`. + + ## Examples + + ```rescript + Int.Bitwise.lsr(8, 1) == 4 + ``` + */ + external lsr: (int, int) => int = "%lsrint" + + /** + `asr(n, length)` calculates the bitwise arithmetic right shift of an integer `n` by `length`. + + ## Examples + + ```rescript + Int.Bitwise.asr(4, 1) == 2 + ``` + */ + external asr: (int, int) => int = "%asrint" +} From 2cdaedfa7ea18d6e54fe0de149fed24193328296 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Wed, 11 Sep 2024 09:11:58 +0200 Subject: [PATCH 04/11] up versions --- package-lock.json | 33 ++++++---------------- package.json | 6 ++-- rescript.json | 2 +- scripts/DocTests.mjs | 17 ++++++++++- scripts/DocTests.res | 5 ++++ test/TypedArrayTests.mjs | 2 +- test/intl/Intl__CollatorTest.mjs | 6 ++-- test/intl/Intl__DateTimeFormatTest.mjs | 2 +- test/intl/Intl__ListFormatTest.mjs | 4 +-- test/intl/Intl__LocaleTest.mjs | 2 +- test/intl/Intl__PluralRulesTest.mjs | 4 +-- test/intl/Intl__RelativeTimeFormatTest.mjs | 4 +-- test/intl/Intl__SegmenterTest.mjs | 4 +-- 13 files changed, 48 insertions(+), 43 deletions(-) diff --git a/package-lock.json b/package-lock.json index 88db17f6..be3b3aa2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,11 +10,11 @@ "license": "MIT", "devDependencies": { "@babel/code-frame": "7.18.6", - "@rescript/tools": "^0.5.0", - "rescript": "^11.1.0-rc.7" + "@rescript/tools": "0.6.4", + "rescript": "11.1.4" }, "peerDependencies": { - "rescript": "^11.1.0-rc.7" + "rescript": ">=11.1.0" } }, "node_modules/@babel/code-frame": { @@ -53,9 +53,9 @@ } }, "node_modules/@rescript/tools": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@rescript/tools/-/tools-0.5.0.tgz", - "integrity": "sha512-gqKZhpXdFMRb0i+aCNKNtbHANFYC/nM7LLLRkkYQLgeJ2teVCV9otO09KIA7CvSZevN6x68r/dkeWi3klLdydA==", + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/@rescript/tools/-/tools-0.6.4.tgz", + "integrity": "sha512-A7RdEEiMnBAN+6FYVseSTP9DPK2jR0Yo0DjZew7Sv4ey88+mwn7lHXTU9cmBlfZBoCPmnnr1e4V2MDbLEX0GUA==", "dev": true, "dependencies": { "rescript": "^11.0.0-rc.7" @@ -67,21 +67,6 @@ "node": "*" } }, - "node_modules/@rescript/tools/node_modules/rescript": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.0.1.tgz", - "integrity": "sha512-7T4PRp/d0+CBNnY6PYKffFqo9tGZlvnZpboF/n+8SKS+JZ6VvXJO7W538VPZXf3EYx1COGAWWvkF9e/HgSAqHg==", - "dev": true, - "hasInstallScript": true, - "bin": { - "bsc": "bsc", - "bstracing": "lib/bstracing", - "rescript": "rescript" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -148,9 +133,9 @@ "dev": true }, "node_modules/rescript": { - "version": "11.1.0-rc.7", - "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.1.0-rc.7.tgz", - "integrity": "sha512-4MsOugrSaS9Sh4grCVwNhOJLv1KZ7gTtN5KsV0ctPvzGyCaco7Ftwqo4uVap7xXuzLjgALPQdYBdElBgTZRvaQ==", + "version": "11.1.4", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-11.1.4.tgz", + "integrity": "sha512-0bGU0bocihjSC6MsE3TMjHjY0EUpchyrREquLS8VsZ3ohSMD+VHUEwimEfB3kpBI1vYkw3UFZ3WD8R28guz/Vw==", "dev": true, "hasInstallScript": true, "bin": { diff --git a/package.json b/package.json index 94c139be..4b1196d2 100644 --- a/package.json +++ b/package.json @@ -24,11 +24,11 @@ "src/**/*.mjs" ], "peerDependencies": { - "rescript": "^11.1.0-rc.7" + "rescript": ">=11.1.0" }, "devDependencies": { "@babel/code-frame": "7.18.6", - "@rescript/tools": "^0.5.0", - "rescript": "^11.1.0-rc.7" + "@rescript/tools": "0.6.4", + "rescript": "11.1.4" } } diff --git a/rescript.json b/rescript.json index 1a54acf9..bcc40ee4 100644 --- a/rescript.json +++ b/rescript.json @@ -18,7 +18,7 @@ ], "suffix": ".mjs", "package-specs": { - "module": "es6", + "module": "esmodule", "in-source": true }, "bs-dev-dependencies": ["@rescript/tools"], diff --git a/scripts/DocTests.mjs b/scripts/DocTests.mjs index da671ade..31c6fe8d 100644 --- a/scripts/DocTests.mjs +++ b/scripts/DocTests.mjs @@ -231,6 +231,21 @@ function getExamples(param) { Core__List.fromArray(match.items) ]); continue ; + case "moduleType" : + _acc = { + hd: { + id: match.id, + kind: "moduleType", + name: match.name, + docstrings: match.docstrings + }, + tl: acc + }; + _items = Belt_List.concatMany([ + items.tl, + Core__List.fromArray(match.items) + ]); + continue ; case "moduleAlias" : _acc = { hd: { @@ -306,7 +321,7 @@ async function main() { var id = example.id.replaceAll(".", "_"); var codes = getCodeBlocks(example); var results = await Promise.all(codes.map(async function (code, $$int) { - var id$1 = id + "_" + $$int.toString(undefined); + var id$1 = id + "_" + $$int.toString(); return await testCode(id$1, code); })); return [ diff --git a/scripts/DocTests.res b/scripts/DocTests.res index 3a448934..ebb92ec3 100644 --- a/scripts/DocTests.res +++ b/scripts/DocTests.res @@ -212,6 +212,11 @@ let getExamples = ({items}: Docgen.doc) => { list{...rest, ...List.fromArray(items)}, list{{id, name, docstrings, kind: "module"}, ...acc}, ) + | list{ModuleType({id, name, docstrings, items}), ...rest} => + loop( + list{...rest, ...List.fromArray(items)}, + list{{id, name, docstrings, kind: "moduleType"}, ...acc}, + ) | list{ModuleAlias({id, name, docstrings, items}), ...rest} => loop( list{...rest, ...List.fromArray(items)}, diff --git a/test/TypedArrayTests.mjs b/test/TypedArrayTests.mjs index 95a7391c..91adb709 100644 --- a/test/TypedArrayTests.mjs +++ b/test/TypedArrayTests.mjs @@ -49,7 +49,7 @@ function assertWillThrow(message, f) { } function areSame(x, y) { - return x.toString(undefined) === y.toString(undefined); + return x.toString() === y.toString(); } assertTrue("fromArray", (function () { diff --git a/test/intl/Intl__CollatorTest.mjs b/test/intl/Intl__CollatorTest.mjs index 1548f993..bbff943d 100644 --- a/test/intl/Intl__CollatorTest.mjs +++ b/test/intl/Intl__CollatorTest.mjs @@ -5,14 +5,14 @@ console.log("---"); console.log("Intl.Collator"); -new Intl.Collator(undefined, undefined); +new Intl.Collator(); -new Intl.Collator(["en-US"], undefined); +new Intl.Collator(["en-US"]); var _collator = new Intl.Collator([ "en-US", "en-GB" - ], undefined); + ]); var collator = new Intl.Collator(["en-US"], { sensitivity: "base", diff --git a/test/intl/Intl__DateTimeFormatTest.mjs b/test/intl/Intl__DateTimeFormatTest.mjs index 2d95e6d9..140ae17c 100644 --- a/test/intl/Intl__DateTimeFormatTest.mjs +++ b/test/intl/Intl__DateTimeFormatTest.mjs @@ -77,7 +77,7 @@ var formatter$6 = new Intl.DateTimeFormat(undefined, (newrecord$4.timeZoneName = console.log(formatter$6.format(new Date(Date.now()))); -var resolvedOptions = new Intl.DateTimeFormat(undefined, undefined).resolvedOptions(); +var resolvedOptions = new Intl.DateTimeFormat().resolvedOptions(); var timeZone = resolvedOptions.timeZone; diff --git a/test/intl/Intl__ListFormatTest.mjs b/test/intl/Intl__ListFormatTest.mjs index 70d37c18..32cc1d48 100644 --- a/test/intl/Intl__ListFormatTest.mjs +++ b/test/intl/Intl__ListFormatTest.mjs @@ -5,12 +5,12 @@ console.log("---"); console.log("Intl.ListFormat"); -new Intl.ListFormat(undefined, undefined); +new Intl.ListFormat(); new Intl.ListFormat([ "en-US", "en-GB" - ], undefined); + ]); var _formatter = new Intl.ListFormat([ "en-US", diff --git a/test/intl/Intl__LocaleTest.mjs b/test/intl/Intl__LocaleTest.mjs index f58897c3..a8349a84 100644 --- a/test/intl/Intl__LocaleTest.mjs +++ b/test/intl/Intl__LocaleTest.mjs @@ -5,7 +5,7 @@ console.log("---"); console.log("Intl.Locale"); -var _locale = new Intl.Locale("en-US", undefined); +var _locale = new Intl.Locale("en-US"); var locale = new Intl.Locale("en-US", { calendar: "hebrew", diff --git a/test/intl/Intl__PluralRulesTest.mjs b/test/intl/Intl__PluralRulesTest.mjs index 786eb15a..3ad44723 100644 --- a/test/intl/Intl__PluralRulesTest.mjs +++ b/test/intl/Intl__PluralRulesTest.mjs @@ -5,12 +5,12 @@ console.log("---"); console.log("Intl.PluralRules"); -new Intl.PluralRules(undefined, undefined); +new Intl.PluralRules(); new Intl.PluralRules([ "en-US", "en-GB" - ], undefined); + ]); var _formatter = new Intl.PluralRules(undefined, { type: "ordinal", diff --git a/test/intl/Intl__RelativeTimeFormatTest.mjs b/test/intl/Intl__RelativeTimeFormatTest.mjs index 9575d4e5..1bfd2627 100644 --- a/test/intl/Intl__RelativeTimeFormatTest.mjs +++ b/test/intl/Intl__RelativeTimeFormatTest.mjs @@ -17,12 +17,12 @@ Intl.RelativeTimeFormat.supportedLocalesOf([ localeMatcher: "lookup" }); -new Intl.RelativeTimeFormat(undefined, undefined); +new Intl.RelativeTimeFormat(); new Intl.RelativeTimeFormat([ "en-US", "en-GB" - ], undefined); + ]); var _formatter = new Intl.RelativeTimeFormat(undefined, { numeric: "always", diff --git a/test/intl/Intl__SegmenterTest.mjs b/test/intl/Intl__SegmenterTest.mjs index 707b4009..841c4ef6 100644 --- a/test/intl/Intl__SegmenterTest.mjs +++ b/test/intl/Intl__SegmenterTest.mjs @@ -17,12 +17,12 @@ Intl.Segmenter.supportedLocalesOf([ localeMatcher: "lookup" }); -new Intl.Segmenter(undefined, undefined); +new Intl.Segmenter(); new Intl.Segmenter([ "en-US", "en-GB" - ], undefined); + ]); var _formatter = new Intl.Segmenter(undefined, { granularity: "word" From 0de657aa870582d1ff7ccbceff8fee1016b6245c Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Wed, 11 Sep 2024 10:00:57 +0200 Subject: [PATCH 05/11] 1.6.0 --- CHANGELOG.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- scripts/DocTests.mjs | 2 +- scripts/DocTests.res | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 870278d6..e146c5bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next version +## 1.6.0 + - Optimize compare and equal functions. https://github.com/rescript-association/rescript-core/pull/238 - Add `make` and `done` + `value` functions to `AsyncIterator`. https://github.com/rescript-association/rescript-core/pull/243 - Int: Add bitwise functions from Pervasives. https://github.com/rescript-association/rescript-core/pull/245 diff --git a/package-lock.json b/package-lock.json index be3b3aa2..ed9daacc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rescript/core", - "version": "1.5.2", + "version": "1.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rescript/core", - "version": "1.5.2", + "version": "1.6.0", "license": "MIT", "devDependencies": { "@babel/code-frame": "7.18.6", diff --git a/package.json b/package.json index 4b1196d2..e9f12072 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/core", - "version": "1.5.2", + "version": "1.6.0", "scripts": { "clean": "rescript clean", "build": "rescript", diff --git a/scripts/DocTests.mjs b/scripts/DocTests.mjs index 31c6fe8d..76bdfeb5 100644 --- a/scripts/DocTests.mjs +++ b/scripts/DocTests.mjs @@ -48,7 +48,7 @@ var bscBin = Path.join(compilerDir, "node_modules", ".bin", "bsc"); var rescriptCoreCompiled = Path.join(compilerDir, "node_modules", "@rescript", "core", "lib", "ocaml"); function makePackageJson(coreVersion) { - return "{\n \"name\": \"test-compiler-examples\",\n \"version\": \"1.0.0\",\n \"dependencies\": {\n \"@rescript/core\": \"file:rescript-core-" + coreVersion + ".tgz\",\n \"rescript\": \"11.1.0-rc.7\"\n }\n}\n"; + return "{\n \"name\": \"test-compiler-examples\",\n \"version\": \"1.0.0\",\n \"dependencies\": {\n \"@rescript/core\": \"file:rescript-core-" + coreVersion + ".tgz\",\n \"rescript\": \"11.1.4\"\n }\n}\n"; } var rescriptJson = "{\n \"name\": \"dummy\",\n \"sources\": {\n \"dir\": \"dummy\",\n \"subdirs\": true\n },\n \"bs-dependencies\": [\n \"@rescript/core\"\n ],\n \"bsc-flags\": [\n \"-open RescriptCore\"\n ]\n}"; diff --git a/scripts/DocTests.res b/scripts/DocTests.res index ebb92ec3..8caa6563 100644 --- a/scripts/DocTests.res +++ b/scripts/DocTests.res @@ -89,7 +89,7 @@ let makePackageJson = coreVersion => "version": "1.0.0", "dependencies": { "@rescript/core": "file:rescript-core-${coreVersion}.tgz", - "rescript": "11.1.0-rc.7" + "rescript": "11.1.4" } } ` From 8d81863cf4d525b5f501dc836e94638bc0bf2489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Cederstr=C3=B6m?= Date: Tue, 15 Oct 2024 21:57:45 +0200 Subject: [PATCH 06/11] Add Set functions (#247) Set.difference Set.intersection Set.union Set.symmetricDifference Set.isSubsetOf Set.isSupersetOf Set.isDisjointFrom Set.toArray --- CHANGELOG.md | 2 + src/Core__Set.res | 10 ++++ src/Core__Set.resi | 133 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e146c5bc..364145bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next version +- Add `difference`, `intersection`, `union`, `symmetricDifference`, `isSubsetOf`, `isSupersetOf`, `isDisjointFrom`, `toArray` functions to `Set`. https://github.com/rescript-association/rescript-core/pull/247 + ## 1.6.0 - Optimize compare and equal functions. https://github.com/rescript-association/rescript-core/pull/238 diff --git a/src/Core__Set.res b/src/Core__Set.res index 6a2ed0fa..4782eb6a 100644 --- a/src/Core__Set.res +++ b/src/Core__Set.res @@ -15,3 +15,13 @@ type t<'a> = Js.Set.t<'a> @send external forEach: (t<'a>, 'a => unit) => unit = "forEach" @send external values: t<'a> => Core__Iterator.t<'a> = "values" + +@send external difference: (t<'a>, t<'a>) => t<'a> = "difference" +@send external intersection: (t<'a>, t<'a>) => t<'a> = "intersection" +@send external union: (t<'a>, t<'a>) => t<'a> = "union" +@send external symmetricDifference: (t<'a>, t<'a>) => t<'a> = "symmetricDifference" +@send external isSubsetOf: (t<'a>, t<'a>) => bool = "isSubsetOf" +@send external isSupersetOf: (t<'a>, t<'a>) => bool = "isSupersetOf" +@send external isDisjointFrom: (t<'a>, t<'a>) => bool = "isDisjointFrom" + +external toArray: t<'a> => array<'a> = "Array.from" diff --git a/src/Core__Set.resi b/src/Core__Set.resi index 297755d0..058e08fa 100644 --- a/src/Core__Set.resi +++ b/src/Core__Set.resi @@ -68,6 +68,8 @@ external fromIterator: Core__Iterator.t<'a> => t<'a> = "Set" /** Returns the size, the number of unique values, of the set. +See [`Set.prototype.size`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/size) on MDN. + ## Examples ```rescript let set = Set.make() @@ -85,6 +87,8 @@ external size: t<'a> => int = "size" /** Clears all entries in the set. +See [`Set.clear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear) on MDN. + ## Examples ```rescript let set = Set.make() @@ -102,6 +106,8 @@ external clear: t<'a> => unit = "clear" /** Adds a new value to the set. +See [`Set.add`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add) on MDN. + ## Examples ```rescript let set = Set.make() @@ -114,6 +120,8 @@ external add: (t<'a>, 'a) => unit = "add" /** Deletes the provided `value` from the set. Returns a `bool` for whether the value existed, and was deleted. +See [`Set.delete`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete) on MDN. + ## Examples ```rescript let set = Set.make() @@ -131,6 +139,8 @@ external delete: (t<'a>, 'a) => bool = "delete" /** Checks whether the set has a specific value. +See [`Set.has`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has) on MDN. + ## Examples ```rescript let set = Set.make() @@ -148,6 +158,8 @@ external has: (t<'a>, 'a) => bool = "has" /** Iterates through all values of the set. +See [`Set.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach) on MDN. + ## Examples ```rescript let set = Set.make() @@ -165,6 +177,8 @@ external forEach: (t<'a>, 'a => unit) => unit = "forEach" /** Returns an iterator that holds all values of the set. +See [`Set.values`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values) on MDN. + ## Examples ```rescript let set = Set.make() @@ -183,3 +197,122 @@ Console.log(set->Set.values->Iterator.toArray) */ @send external values: t<'a> => Core__Iterator.t<'a> = "values" + +/** +Returns a new set with the values of the set that are not in the other set. + +See [`Set.difference`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference) on MDN. + +## Examples +```rescript +let set1 = Set.fromArray(["apple", "orange", "banana"]) +let set2 = Set.fromArray(["apple", "banana", "pear"]) +set1->Set.difference(set2) // Set.fromArray(["orange"]) +``` +*/ +@send +external difference: (t<'a>, t<'a>) => t<'a> = "difference" + +/** +Returns a new set with the values containing the values which are in either the set, but not in both. + +See [`Set.symmetricDifference`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/symmetricDifference) on MDN. + +## Examples +```rescript +let set1 = Set.fromArray(["apple", "orange", "banana"]) +let set2 = Set.fromArray(["apple", "banana", "pear"]) +set1->Set.symmetricDifference(set2) // Set.fromArray(["orange", "pear"]) +``` + +*/ +@send +external symmetricDifference: (t<'a>, t<'a>) => t<'a> = "symmetricDifference" + +/** +Returns a new set with the values containing the values which are in both the set and the other set. + +See [`Set.intersection`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection) on MDN. + +## Examples +```rescript +let set1 = Set.fromArray(["apple", "orange", "banana"]) +let set2 = Set.fromArray(["apple", "banana", "pear"]) +set1->Set.intersection(set2) // Set.fromArray(["apple", "banana"]) +``` +*/ +@send +external intersection: (t<'a>, t<'a>) => t<'a> = "intersection" + +/** +Returns a bool indicating if this set has no elements in common with the given set. + +See [`Set.isDisjointFrom`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isDisjointFrom) on MDN. + +## Examples +```rescript +let set1 = Set.fromArray(["apple", "orange", "banana"]) +let set2 = Set.fromArray(["kiwi", "melon", "pear"]) +set1->Set.isDisjointFrom(set2) // true +``` +*/ +@send +external isDisjointFrom: (t<'a>, t<'a>) => bool = "isDisjointFrom" + +/** +Returns a bool indicating if the all values in the set are in the given set. + +See [`Set.isSubsetOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSubsetOf) on MDN. + +## Examples +```rescript +let set1 = Set.fromArray(["apple", "banana"]) +let set2 = Set.fromArray(["apple", "banana", "pear"]) +set1->Set.isSubsetOf(set2) // true +``` + */ +@send +external isSubsetOf: (t<'a>, t<'a>) => bool = "isSubsetOf" + +/** +Returns a bool indicating if the all values in the given set are in the set. + +See [`Set.isSupersetOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/isSupersetOf) on MDN. + +## Examples +```rescript +let set1 = Set.fromArray(["apple", "banana", "pear"]) +let set2 = Set.fromArray(["apple", "banana"]) +set1->Set.isSupersetOf(set2) // true + ``` +*/ +@send +external isSupersetOf: (t<'a>, t<'a>) => bool = "isSupersetOf" + +/** + Returns a new set with the values of the set that are in both the set and the other set. + +See [`Set.union`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/union) on MDN. + +## Examples +```rescript +let set1 = Set.fromArray(["apple", "orange", "banana"]) +let set2 = Set.fromArray(["apple", "banana", "pear"]) +set1->Set.union(set2) // Set.fromArray(["apple", "orange", "banana", "pear"]) +``` +*/ +@send +external union: (t<'a>, t<'a>) => t<'a> = "union" + +/** +`toArray(set)` returns an array of all values of the set. + +See [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) on MDN. + +## Examples +```rescript +let set = Set.fromArray(["apple", "orange", "apple", "banana"]) +set->Set.toArray // ["apple", "orange", "banana"] +``` +*/ +external toArray: t<'a> => array<'a> = "Array.from" From 61456903504dc249d7ded021935f57af736fa10a Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Wed, 16 Oct 2024 09:33:14 +0200 Subject: [PATCH 07/11] 1.6.1 --- CHANGELOG.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 364145bc..4b3d5727 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next version +## 1.6.1 + - Add `difference`, `intersection`, `union`, `symmetricDifference`, `isSubsetOf`, `isSupersetOf`, `isDisjointFrom`, `toArray` functions to `Set`. https://github.com/rescript-association/rescript-core/pull/247 ## 1.6.0 diff --git a/package-lock.json b/package-lock.json index ed9daacc..413838e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rescript/core", - "version": "1.6.0", + "version": "1.6.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@rescript/core", - "version": "1.6.0", + "version": "1.6.1", "license": "MIT", "devDependencies": { "@babel/code-frame": "7.18.6", diff --git a/package.json b/package.json index e9f12072..6654bdd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rescript/core", - "version": "1.6.0", + "version": "1.6.1", "scripts": { "clean": "rescript clean", "build": "rescript", From 50160e4456a8223412fb37c2efedbc772278e46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=87=E5=AE=87=E7=A5=A5?= Date: Thu, 17 Oct 2024 03:00:28 +0800 Subject: [PATCH 08/11] fix dataview bindings (#246) * fix dataview bindings * Update CHANGELOG.md --- CHANGELOG.md | 1 + src/Core__DataView.res | 50 +++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b3d5727..f41e3a15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ## 1.6.1 - Add `difference`, `intersection`, `union`, `symmetricDifference`, `isSubsetOf`, `isSupersetOf`, `isDisjointFrom`, `toArray` functions to `Set`. https://github.com/rescript-association/rescript-core/pull/247 +- Fix bindings of DataView. https://github.com/rescript-association/rescript-core/pull/246 ## 1.6.0 diff --git a/src/Core__DataView.res b/src/Core__DataView.res index 83e09368..22c6e9a4 100644 --- a/src/Core__DataView.res +++ b/src/Core__DataView.res @@ -10,28 +10,28 @@ external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: i @get external byteLength: t => int = "byteLength" @get external byteOffset: t => int = "byteOffset" -@send external getInt8: t => int = "getInt8" -@send external getUint8: t => int = "getUint8" -@send external getInt16: t => int = "getInt16" -@send external getUint16: t => int = "getUint16" -@send external getInt32: t => int = "getInt32" -@send external getUint32: t => int = "getUint32" - -@send external getFloat32: t => float = "getFloat32" -@send external getFloat64: t => float = "getFloat64" - -@send external getBigInt64: t => bigint = "getBigInt64" -@send external getBigUint64: t => bigint = "getBigUint64" - -@send external setInt8: (t, int) => unit = "setInt8" -@send external setUint8: (t, int) => unit = "setUint8" -@send external setInt16: (t, int) => unit = "setInt16" -@send external setUint16: (t, int) => unit = "setUint16" -@send external setInt32: (t, int) => unit = "setInt32" -@send external setUint32: (t, int) => unit = "setUint32" - -@send external setFloat32: (t, float) => unit = "setFloat32" -@send external setFloat64: (t, float) => unit = "setFloat64" - -@send external setBigInt64: (t, bigint) => unit = "setBigInt64" -@send external setBigUint64: (t, bigint) => unit = "setBigUint64" +@send external getInt8: (t, int) => int = "getInt8" +@send external getUint8: (t, int) => int = "getUint8" +@send external getInt16: (t, int) => int = "getInt16" +@send external getUint16: (t, int) => int = "getUint16" +@send external getInt32: (t, int) => int = "getInt32" +@send external getUint32: (t, int) => int = "getUint32" + +@send external getFloat32: (t, int) => float = "getFloat32" +@send external getFloat64: (t, int) => float = "getFloat64" + +@send external getBigInt64: (t, int) => bigint = "getBigInt64" +@send external getBigUint64: (t, int) => bigint = "getBigUint64" + +@send external setInt8: (t, int, int) => unit = "setInt8" +@send external setUint8: (t, int, int) => unit = "setUint8" +@send external setInt16: (t, int, int) => unit = "setInt16" +@send external setUint16: (t, int, int) => unit = "setUint16" +@send external setInt32: (t, int, int) => unit = "setInt32" +@send external setUint32: (t, int, int) => unit = "setUint32" + +@send external setFloat32: (t, int, float) => unit = "setFloat32" +@send external setFloat64: (t, int, float) => unit = "setFloat64" + +@send external setBigInt64: (t, int, bigint) => unit = "setBigInt64" +@send external setBigUint64: (t, int, bigint) => unit = "setBigUint64" From e230098edbca2043b932261ae019d6293d0213e5 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Wed, 16 Oct 2024 21:01:23 +0200 Subject: [PATCH 09/11] move changelog to the correct place --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f41e3a15..f5c8ed3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,11 @@ ## Next version +- Fix bindings of DataView. https://github.com/rescript-association/rescript-core/pull/246 + ## 1.6.1 - Add `difference`, `intersection`, `union`, `symmetricDifference`, `isSubsetOf`, `isSupersetOf`, `isDisjointFrom`, `toArray` functions to `Set`. https://github.com/rescript-association/rescript-core/pull/247 -- Fix bindings of DataView. https://github.com/rescript-association/rescript-core/pull/246 ## 1.6.0 From f042582a9067a524e106250bdd20f970bafc21cc Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 3 Dec 2024 17:34:52 +0900 Subject: [PATCH 10/11] fix: incorrect comment on Math.sign (#249) --- src/Core__Math.resi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core__Math.resi b/src/Core__Math.resi index ef146f9b..1216f72e 100644 --- a/src/Core__Math.resi +++ b/src/Core__Math.resi @@ -788,7 +788,7 @@ See [`Math.sign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refere ```rescript Math.sign(3.0) // 1.0 -Math.sign(-3.0) // 1.0 +Math.sign(-3.0) // -1.0 Math.sign(0.0) // 0.0 ``` */ From 241012986a2e63dcdd4aa8d2013113fdf28af906 Mon Sep 17 00:00:00 2001 From: illusionalsagacity Date: Thu, 20 Feb 2025 14:58:07 -0500 Subject: [PATCH 11/11] docs: updates the link in Math.ceil's docstring to point at the right place (#251) resolves #250 --- src/Core__Math.resi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core__Math.resi b/src/Core__Math.resi index 1216f72e..255edaae 100644 --- a/src/Core__Math.resi +++ b/src/Core__Math.resi @@ -294,7 +294,7 @@ module Int: { /** ceil(v) returns the smallest `int` greater than or equal to the argument; - See [`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor) + See [`Math.ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil) on MDN. ## Examples