diff --git a/src/Array/difference.luau b/src/Array/difference.luau index 07966e1..121a2aa 100644 --- a/src/Array/difference.luau +++ b/src/Array/difference.luau @@ -7,12 +7,12 @@ local toSet = require("./toSet") Returns a new array containing only values that are in the first array and not in any of the other arrays. - ```lua - local array1 = { 1, 2, 3 } - local array2 = { 2, 3, 4 } + ```lua + local array1 = { 1, 2, 3 } + local array2 = { 2, 3, 4 } - difference(array1, array2) -- { 1 } - ``` + difference(array1, array2) -- { 1 } + ``` ]=] local function difference(array: { T }, ...: { T }): { T } local arraySet = toSet(array) diff --git a/src/Array/zip.luau b/src/Array/zip.luau index fe5b5b5..21f43df 100644 --- a/src/Array/zip.luau +++ b/src/Array/zip.luau @@ -10,7 +10,7 @@ local reduce = require("./reduce") local array2 = { 1, 2, 3 } zip(array1, array2) - -- { { "a", 1 }, { "b", 2 }, { "c", 3 } } + -- { { "a", 1 }, { "b", 2 }, { "c", 3 } } ``` ]=] local function zip(...: { any }): { { any } } diff --git a/src/Dictionary/get.luau b/src/Dictionary/get.luau index f41481d..61ff4b3 100644 --- a/src/Dictionary/get.luau +++ b/src/Dictionary/get.luau @@ -1,21 +1,21 @@ --[=[ @within Dictionary - Retrieves a value from a dictionary using a key. If the key is a dot-separated string and the `separated` parameter is `true`, the function will traverse the dictionary using the parts of the string as keys. If `separated` is a string, it'll be used as the separator. If the key is not found, the function will return `nil`. - - ```lua - local dictionary = { - foo = { - bar = { - baz = "qux" - } - } - } - - get(dictionary, "foo.bar.baz") -- nil - get(dictionary, "foo.bar.baz", true) -- "qux" - get(dictionary, "foo$bar$baz", "$") -- "qux" - ``` + Retrieves a value from a dictionary using a key. If the key is a dot-separated string and the `separated` parameter is `true`, the function will traverse the dictionary using the parts of the string as keys. If `separated` is a string, it'll be used as the separator. If the key is not found, the function will return `nil`. + + ```lua + local dictionary = { + foo = { + bar = { + baz = "qux" + } + } + } + + get(dictionary, "foo.bar.baz") -- nil + get(dictionary, "foo.bar.baz", true) -- "qux" + get(dictionary, "foo$bar$baz", "$") -- "qux" + ``` ]=] local function get(dictionary: { [K]: V }, key: K, separated: (string | boolean)?): V? if not separated then diff --git a/src/Dictionary/mergeDeep.luau b/src/Dictionary/mergeDeep.luau index 31ab2c1..c8bfefa 100644 --- a/src/Dictionary/mergeDeep.luau +++ b/src/Dictionary/mergeDeep.luau @@ -4,15 +4,15 @@ local copyDeep = require("./copyDeep") --[=[ @within Dictionary - Combines multiple dictionaries into a single dictionary, including nested dictionaries. + Combines multiple dictionaries into a single dictionary, including nested dictionaries. - ```lua - local dictionary1 = { foo = "bar", deep = { foo = "bar" } } - local dictionary2 = { deep = { foo = "baz" } } + ```lua + local dictionary1 = { foo = "bar", deep = { foo = "bar" } } + local dictionary2 = { deep = { foo = "baz" } } - mergeDeep(dictionary1, dictionary2) - -- { foo = "bar", deep = { foo = "baz" } } - ``` + mergeDeep(dictionary1, dictionary2) + -- { foo = "bar", deep = { foo = "baz" } } + ``` ]=] local function mergeDeep(...: { [any]: any }): { [K]: V } local out: any = {} diff --git a/src/Dictionary/patchDiff.luau b/src/Dictionary/patchDiff.luau index aa8685c..852d43d 100644 --- a/src/Dictionary/patchDiff.luau +++ b/src/Dictionary/patchDiff.luau @@ -9,39 +9,31 @@ export type Patch = { --[=[ @within Dictionary - Returns an array of patches that can be applied to `dictionary` to make it equal to `other`. This is a deep comparison. The patches are similar to those used in JSON Patch. + Returns an array of patches that can be applied to `dictionary` to make it equal to `other`. This is a deep comparison. The patches are similar to those used in [JSON Patch](https://jsonpatch.com/). - ```lua - local dictionary1 = { - foo = "bar", - qux = { - baz = "quux", - }, - } + ```lua + local dictionary1 = { + foo = "bar", + qux = { + baz = "quux", + }, + } - local dictionary2 = { - foo = "bar", - qux = { - baz = "quuz", - }, - baz = "quux", - } + local dictionary2 = { + foo = "bar", + qux = { + baz = "quuz", + }, + baz = "quux", + } - patchDiff(dictionary1, dictionary2) --[[ - { - { - op = "replace", - path = { "qux", "baz" }, - value = "quuz", - }, - { - op = "add", - path = { "baz" }, - value = "quux", - }, - } - ]] - ``` + patchDiff(dictionary1, dictionary2) --[[ + { + { op = "replace", path = { "qux", "baz" }, value = "quuz" }, + { op = "add", path = { "baz" }, value = "quux" }, + } + ]] + ``` ]=] local function patchDiff(dictionary: { [K]: V }, other: { [K]: V }): { Patch } local out: { any } = {} diff --git a/src/Dictionary/update.luau b/src/Dictionary/update.luau index 8c2a935..dc63b75 100644 --- a/src/Dictionary/update.luau +++ b/src/Dictionary/update.luau @@ -4,19 +4,19 @@ local copy = require("./copy") --[=[ @within Dictionary - Updates a value in a dictionary with a given key. If the key does not exist, the value is added to the dictionary using the provided adder function. + Updates a value in a dictionary with a given key. If the key does not exist, the value is added to the dictionary using the provided adder function. - ```lua - local dictionary = { a = 1, b = 2 } + ```lua + local dictionary = { a = 1, b = 2 } - update(dictionary, "b", function(value) - return value + 1 - end) -- { a = 1, b = 3 } + update(dictionary, "b", function(value) + return value + 1 + end) -- { a = 1, b = 3 } - update(dictionary, "c", nil, function() - return 3 - end) -- { a = 1, b = 2, c = 3 } - ``` + update(dictionary, "c", nil, function() + return 3 + end) -- { a = 1, b = 2, c = 3 } + ``` ]=] local function update( dictionary: { [K]: V }, diff --git a/src/None.luau b/src/None.luau index 17aac5d..16326e2 100644 --- a/src/None.luau +++ b/src/None.luau @@ -1,13 +1,13 @@ --[=[ - @within Sift - @prop None None + @within Sift + @prop None None - Luau doesn't have a built-in `undefined` type, so Sift provides a `None` value to represent the absence of a value. + Luau doesn't have a built-in `undefined` type, so Sift provides a `None` value to represent the absence of a value. - ```lua - merge({ foo = "bar", baz = "qux" }, { foo = Sift.None }) - -- { baz = "qux" } - ``` + ```lua + merge({ foo = "bar", baz = "qux" }, { foo = Sift.None }) + -- { baz = "qux" } + ``` ]=] local None: unknown = newproxy(true) diff --git a/src/Set/copy.luau b/src/Set/copy.luau index 8269234..b53379d 100644 --- a/src/Set/copy.luau +++ b/src/Set/copy.luau @@ -1,11 +1,11 @@ --[=[ @within Set - Returns a shallow copy of the set. + Returns a shallow copy of the set. - ```lua - copy({ a = true, b = true }) -- { a = true, b = true } - ``` + ```lua + copy({ a = true, b = true }) -- { a = true, b = true } + ``` ]=] local function copy(set: { [T]: boolean }): { [T]: boolean } local out = {}