diff --git a/chiller.json b/chiller.json index c2bf6b9f..2d93bbe4 100644 --- a/chiller.json +++ b/chiller.json @@ -44,4 +44,4 @@ "Typed" ] } -} \ No newline at end of file +} diff --git a/docs/array/boil.mdx b/docs/array/boil.mdx index 3e6ed8aa..531e48d5 100644 --- a/docs/array/boil.mdx +++ b/docs/array/boil.mdx @@ -26,6 +26,6 @@ const gods = [ } ] -boil(gods, (a, b) => (a.power > b.power ? a : b)) +boil(gods, (a, b) => (a.power > b.power ? a : b)) // => { name: 'Ra', power: 100 } ``` diff --git a/docs/array/cluster.mdx b/docs/array/cluster.mdx index 19f64237..e3411813 100644 --- a/docs/array/cluster.mdx +++ b/docs/array/cluster.mdx @@ -13,7 +13,18 @@ split as evenly as possible. ```ts import { cluster } from 'radash' -const gods = ['Ra', 'Zeus', 'Loki', 'Vishnu', 'Icarus', 'Osiris', 'Thor', 'Apollo', 'Artemis', 'Athena'] +const gods = [ + 'Ra', + 'Zeus', + 'Loki', + 'Vishnu', + 'Icarus', + 'Osiris', + 'Thor', + 'Apollo', + 'Artemis', + 'Athena' +] cluster(gods, 3) // => [ diff --git a/docs/array/list.mdx b/docs/array/list.mdx index c993ae4d..9a80e97a 100644 --- a/docs/array/list.mdx +++ b/docs/array/list.mdx @@ -15,14 +15,14 @@ _A hat tip to Python's `range` functionality_ ```ts import { list } from 'radash' -list(3) // [0, 1, 2, 3] -list(0, 3) // [0, 1, 2, 3] -list(0, 3, 'y') // [y, y, y, y] -list(0, 3, () => 'y') // [y, y, y, y] -list(0, 3, i => i) // [0, 1, 2, 3] +list(3) // [0, 1, 2, 3] +list(0, 3) // [0, 1, 2, 3] +list(0, 3, 'y') // [y, y, y, y] +list(0, 3, () => 'y') // [y, y, y, y] +list(0, 3, i => i) // [0, 1, 2, 3] list(0, 3, i => `y${i}`) // [y0, y1, y2, y3] -list(0, 3, obj) // [obj, obj, obj, obj] -list(0, 6, i => i, 2) // [0, 2, 4, 6] +list(0, 3, obj) // [obj, obj, obj, obj] +list(0, 6, i => i, 2) // [0, 2, 4, 6] ``` ## Signatures @@ -50,9 +50,9 @@ list(2, 6) // [2, 3, 4, 5, 6] When given a third argument it's treated as the `value` to be used in the list. If the `value` is a function it will be called, with an index argument, to create every value. ```ts -list(2, 4, {}) // [{}, {}, {}] -list(2, 4, null) // [null, null, null] -list(2, 4, (i) => i) // [2, 3, 4] +list(2, 4, {}) // [{}, {}, {}] +list(2, 4, null) // [null, null, null] +list(2, 4, i => i) // [2, 3, 4] ``` ### list(start, end, value, step) @@ -60,6 +60,6 @@ list(2, 4, (i) => i) // [2, 3, 4] When given a fourth argument it's treated as the `step` size to skip when generating values from `start` to `end`. ```ts -list(2, 4, i => i, 2) // [2, 4] -list(25, 100, i => i, 25) // [25, 50, 75, 100] -``` \ No newline at end of file +list(2, 4, i => i, 2) // [2, 4] +list(25, 100, i => i, 25) // [25, 50, 75, 100] +``` diff --git a/docs/array/range.mdx b/docs/array/range.mdx index 9083c8d0..3303870d 100644 --- a/docs/array/range.mdx +++ b/docs/array/range.mdx @@ -15,14 +15,14 @@ _A hat tip to Python's `range` functionality_ ```ts import { range } from 'radash' -range(3) // yields 0, 1, 2, 3 -range(0, 3) // yields 0, 1, 2, 3 -range(0, 3, 'y') // yields y, y, y, y -range(0, 3, () => 'y') // yields y, y, y, y -range(0, 3, i => i) // yields 0, 1, 2, 3 +range(3) // yields 0, 1, 2, 3 +range(0, 3) // yields 0, 1, 2, 3 +range(0, 3, 'y') // yields y, y, y, y +range(0, 3, () => 'y') // yields y, y, y, y +range(0, 3, i => i) // yields 0, 1, 2, 3 range(0, 3, i => `y${i}`) // yields y0, y1, y2, y3 -range(0, 3, obj) // yields obj, obj, obj, obj -range(0, 6, i => i, 2) // yields 0, 2, 4, 6 +range(0, 3, obj) // yields obj, obj, obj, obj +range(0, 6, i => i, 2) // yields 0, 2, 4, 6 for (const i of range(0, 200, 10)) { console.log(i) // => 0, 10, 20, 30 ... 190, 200 @@ -58,9 +58,9 @@ range(2, 6) // yields 2, 3, 4, 5, 6 When given a third argument it's treated as the `value` to be yielded in the generator. If the `value` is a function it will be called, with an index argument, to create every value. ```ts -range(2, 4, {}) // yields {}, {}, {} -range(2, 4, null) // yields null, null, null -range(2, 4, (i) => i) // yields 2, 3, 4 +range(2, 4, {}) // yields {}, {}, {} +range(2, 4, null) // yields null, null, null +range(2, 4, i => i) // yields 2, 3, 4 ``` ### range(start, end, value, step) @@ -68,6 +68,6 @@ range(2, 4, (i) => i) // yields 2, 3, 4 When given a fourth argument it's treated as the `step` size to skip when yielding values from `start` to `end`. ```ts -range(2, 4, i => i, 2) // yields 2, 4 -range(25, 100, i => i, 25) // yields 25, 50, 75, 100 -``` \ No newline at end of file +range(2, 4, i => i, 2) // yields 2, 4 +range(25, 100, i => i, 25) // yields 25, 50, 75, 100 +``` diff --git a/docs/array/toggle.mdx b/docs/array/toggle.mdx index 55a21421..e6739b0d 100644 --- a/docs/array/toggle.mdx +++ b/docs/array/toggle.mdx @@ -13,7 +13,7 @@ import { toggle } from 'radash' const gods = ['ra', 'zeus', 'loki'] -toggle(gods, 'ra') // => [zeus, loki] +toggle(gods, 'ra') // => [zeus, loki] toggle(gods, 'vishnu') // => [ra, zeus, loki, vishnu] ``` @@ -31,7 +31,7 @@ const vishnu = { name: 'Vishnu' } const gods = [ra, zeus, loki] -toggle(gods, ra, g => g.name) // => [zeus, loki] +toggle(gods, ra, g => g.name) // => [zeus, loki] toggle(gods, vishnu, g => g.name) // => [ra, zeus, loki, vishnu] ``` diff --git a/docs/array/unique.mdx b/docs/array/unique.mdx index 82b64fa5..cc37f3ed 100644 --- a/docs/array/unique.mdx +++ b/docs/array/unique.mdx @@ -31,7 +31,7 @@ const fish = [ } ] -unique( fish, f => f.name ) +unique(fish, f => f.name) // [ // { name: 'Marlin', weight: 105, source: 'ocean' }, // { name: 'Salmon', weight: 22, source: 'river' } diff --git a/docs/async/defer.mdx b/docs/async/defer.mdx index 7f43b4aa..9259879f 100644 --- a/docs/async/defer.mdx +++ b/docs/async/defer.mdx @@ -4,19 +4,16 @@ group: 'Async' description: Run an async function with deferred functions --- - - - ## Basic usage -The `_.defer` functions lets you run an async function, registering functions as you go -that should be deferred until the async function completes, and then executed. This is -really useful in scripts where failure up to or after a specific point will require some -cleanup. It's a bit like a `finally` block. +The `_.defer` functions lets you run an async function, registering functions as you go +that should be deferred until the async function completes, and then executed. This is +really useful in scripts where failure up to or after a specific point will require some +cleanup. It's a bit like a `finally` block. -A hat tip to Swift's `defer` for the inspiration. +A hat tip to Swift's `defer` for the inspiration. -The function passed to `_.defer` is called with a single `register` function argument that +The function passed to `_.defer` is called with a single `register` function argument that can be used to register the work you want to be called when the function completes. If your function throws an error and then a registered cleanup function throws and error it is ignored by default. The register function supports an optional second `options` argument that lets you configure a rethrow @@ -25,7 +22,7 @@ strategy so that error in the cleanup function is rethrown. ```ts import { defer } from 'radash' -await defer(async (cleanup) => { +await defer(async cleanup => { const buildDir = await createBuildDir() cleanup(() => fs.unlink(buildDir)) @@ -33,7 +30,7 @@ await defer(async (cleanup) => { await build() }) -await defer(async (register) => { +await defer(async register => { const org = await api.org.create() register(async () => api.org.delete(org.id), { rethrow: true }) @@ -43,10 +40,3 @@ await defer(async (register) => { await executeTest(org, user) }) ``` - - - - - - - diff --git a/docs/async/map.mdx b/docs/async/map.mdx index a41679b1..5275aa7e 100644 --- a/docs/async/map.mdx +++ b/docs/async/map.mdx @@ -4,9 +4,6 @@ group: 'Async' description: Map an array with an async function --- - - - ## Basic usage A map that handles callback functions that return a promise. @@ -16,14 +13,7 @@ import { map } from 'radash' const userIds = [1, 2, 3, 4] -const users = await map(userIds, async (userId) => { +const users = await map(userIds, async userId => { return await api.users.find(userId) }) ``` - - - - - - - diff --git a/docs/async/parallel.mdx b/docs/async/parallel.mdx index 37cd9c99..6bc0fccb 100644 --- a/docs/async/parallel.mdx +++ b/docs/async/parallel.mdx @@ -4,9 +4,6 @@ group: 'Async' description: Run many async function in parallel --- - - - ## Basic usage Like `_.map` but built specifically to run the async callback functions @@ -20,7 +17,7 @@ const userIds = [1, 2, 3, 4, 5, 6, 7, 8, 9] // Will run the find user async function 3 at a time // starting another request when one of the 3 is freed -const users = await parallel(3, userIds, async (userId) => { +const users = await parallel(3, userIds, async userId => { return await api.users.find(userId) }) ``` @@ -28,7 +25,7 @@ const users = await parallel(3, userIds, async (userId) => { ## Errors When all work is complete parallel will check for errors. If any -occurred they will all be thrown in a single `AggregateError` that +occurred they will all be thrown in a single `AggregateError` that has an `errors` property that is all the errors that were thrown. ```ts @@ -36,7 +33,7 @@ import { parallel, try as tryit } from 'radash' const userIds = [1, 2, 3] -const [err, users] = await tryit(parallel)(3, userIds, async (userId) => { +const [err, users] = await tryit(parallel)(3, userIds, async userId => { throw new Error(`No, I don\'t want to find user ${userId}`) }) @@ -44,10 +41,3 @@ console.log(err) // => AggregateError console.log(err.errors) // => [Error, Error, Error] console.log(err.errors[1].message) // => No, I don't want to find user 2 ``` - - - - - - - diff --git a/docs/async/reduce.mdx b/docs/async/reduce.mdx index 8bcccace..d5f31eb1 100644 --- a/docs/async/reduce.mdx +++ b/docs/async/reduce.mdx @@ -4,9 +4,6 @@ group: 'Async' description: Reduce an array with an async function --- - - - ## Basic usage A reduce that handles callback functions that return a promise. @@ -16,18 +13,15 @@ import { reduce } from 'radash' const userIds = [1, 2, 3, 4] -const users = await reduce(userIds, async (acc, userId) => { - const user = await api.users.find(userId) - return { - ...acc, - [userId]: user - } -}, {}) +const users = await reduce( + userIds, + async (acc, userId) => { + const user = await api.users.find(userId) + return { + ...acc, + [userId]: user + } + }, + {} +) ``` - - - - - - - diff --git a/docs/async/retry.mdx b/docs/async/retry.mdx index 6ba95ce6..d3721917 100644 --- a/docs/async/retry.mdx +++ b/docs/async/retry.mdx @@ -4,14 +4,11 @@ group: 'Async' description: Run an async function retrying if it fails --- - - - ## Basic usage -The `_.retry` function allows you to run an async function and automagically retry it if it fails. Given the async func to run, an optional max number of retries (`r`), and an optional milliseconds to delay between retries (`d`), the given async function will be called, retrying `r` many times, and waiting `d` milliseconds between retries. +The `_.retry` function allows you to run an async function and automagically retry it if it fails. Given the async func to run, an optional max number of retries (`r`), and an optional milliseconds to delay between retries (`d`), the given async function will be called, retrying `r` many times, and waiting `d` milliseconds between retries. -The `times` option defaults to `3`. The `delay` option (defaults to null) can specify milliseconds to sleep between attempts. +The `times` option defaults to `3`. The `delay` option (defaults to null) can specify milliseconds to sleep between attempts. The `backoff` option is like delay but uses a function to sleep -- makes for easy exponential backoff. @@ -23,12 +20,5 @@ await retry({ times: 10 }, api.users.list) await retry({ times: 2, delay: 1000 }, api.users.list) // exponential backoff -await retry({ backoff: i => 10**i }, api.users.list) +await retry({ backoff: i => 10 ** i }, api.users.list) ``` - - - - - - - diff --git a/docs/async/sleep.mdx b/docs/async/sleep.mdx index e7916894..f8d06c2a 100644 --- a/docs/async/sleep.mdx +++ b/docs/async/sleep.mdx @@ -4,9 +4,6 @@ group: 'Async' description: Asynchronously wait for time to pass --- - - - ## Basic usage The `_.sleep` function allows you to delay in milliseconds. @@ -16,11 +13,3 @@ import { sleep } from 'radash' await sleep(2000) // => waits 2 seconds ``` - - - - - - - - diff --git a/docs/core-concepts.mdx b/docs/core-concepts.mdx index f96ea0a7..f34c2877 100644 --- a/docs/core-concepts.mdx +++ b/docs/core-concepts.mdx @@ -1,14 +1,14 @@ --- -title: "Core Concepts" -group: "Getting Started" -description: "Why is Radash so dashing?" +title: 'Core Concepts' +group: 'Getting Started' +description: 'Why is Radash so dashing?' --- ## Keep it Simple ### Readable -The Radash source is easy to read and understand. We don't make you navigate through internal library modules and classes, reading a hundred lines of code, to understand what a function does or how it works. +The Radash source is easy to read and understand. We don't make you navigate through internal library modules and classes, reading a hundred lines of code, to understand what a function does or how it works. As an example, here's a look at [the source](https://github.com/rayepps/radash/blob/master/src/curry.ts#L11-L13) for the `_.compose` function. @@ -29,4 +29,3 @@ Functional programming has incredible design patterns that we often pull from. H ### Types Radash is written in TypeScript and provides full typing out of the box. - diff --git a/docs/curry/chain.mdx b/docs/curry/chain.mdx index 3e27f540..d47710a4 100644 --- a/docs/curry/chain.mdx +++ b/docs/curry/chain.mdx @@ -7,6 +7,7 @@ description: Create a chain of function to run in order ## Basic usage Chaining functions will cause them to execute one after another, passing the output from each function as the input to the next, returning the final output at the end of the chain. + ```ts import { chain } from 'radash' @@ -22,12 +23,13 @@ chained(7) // => 24 ``` ### Example + ```ts import { chain } from 'radash' -type Deity = { +type Deity = { name: string - rank: number + rank: number } const gods: Deity[] = [ @@ -39,11 +41,8 @@ const gods: Deity[] = [ const getName = (god: Deity) => item.name const upperCase = (text: string) => text.toUpperCase() as Uppercase -const getUpperName = chain( - getName, - upperCase -) +const getUpperName = chain(getName, upperCase) -getUpperName(gods[0]) // => 'RA' -gods.map(getUpperName) // => ['RA', 'ZEUS', 'LOKI'] +getUpperName(gods[0]) // => 'RA' +gods.map(getUpperName) // => ['RA', 'ZEUS', 'LOKI'] ``` diff --git a/docs/curry/compose.mdx b/docs/curry/compose.mdx index 4c0f8283..309aa0a4 100644 --- a/docs/curry/compose.mdx +++ b/docs/curry/compose.mdx @@ -4,9 +4,6 @@ group: 'Curry' description: Create a composition of functions --- - - - ## Basic usage In a composition of functions, each function is given the next function as an argument and must call it to continue executing. @@ -16,7 +13,10 @@ import { compose } from 'radash' const useZero = (fn: any) => () => fn(0) const objectize = (fn: any) => (num: any) => fn({ num }) -const increment = (fn: any) => ({ num }: any) => fn({ num: num + 1 }) +const increment = + (fn: any) => + ({ num }: any) => + fn({ num: num + 1 }) const returnArg = (arg: any) => (args: any) => args[arg] const composed = compose( @@ -33,20 +33,7 @@ composed() // => 2 This can be a little jarring if you haven't seen it before. Here's a broken down composition. It's equivelent to the code above. ```ts -const decomposed = ( - useZero( - objectize( - increment( - increment( - returnArg('num'))))) -) +const decomposed = useZero(objectize(increment(increment(returnArg('num'))))) decomposed() // => 2 ``` - - - - - - - diff --git a/docs/curry/debounce.mdx b/docs/curry/debounce.mdx index da28386a..8b3f599e 100644 --- a/docs/curry/debounce.mdx +++ b/docs/curry/debounce.mdx @@ -14,7 +14,7 @@ in invoking the source reset the delay, pushing off the next invocation. ```ts import { debounce } from 'radash' -const makeSearchRequest = (event) => { +const makeSearchRequest = event => { api.movies.search(event.target.value) } @@ -68,4 +68,3 @@ const debounced = debounce({ delay: 100 }, api.feed.refresh) debounced.isPending() ``` - diff --git a/docs/curry/memo.mdx b/docs/curry/memo.mdx index a34bcf47..2948983a 100644 --- a/docs/curry/memo.mdx +++ b/docs/curry/memo.mdx @@ -4,9 +4,6 @@ group: 'Curry' description: Memoize a function --- - - - ## Basic usage Wrap a function with memo to get a function back that automagically returns values that have already been calculated. @@ -49,12 +46,15 @@ now === muchLater // => false You can optionally customize how values are stored when memoized. ```ts -const timestamp = memo(({ group }: { group: string }) => { - const ts = Date.now() - return `${ts}::${group}` -}, { - key: ({ group }: { group: string }) => group -}) +const timestamp = memo( + ({ group }: { group: string }) => { + const ts = Date.now() + return `${ts}::${group}` + }, + { + key: ({ group }: { group: string }) => group + } +) const now = timestamp({ group: 'alpha' }) const later = timestamp({ group: 'alpha' }) @@ -63,10 +63,3 @@ const beta = timestamp({ group: 'beta' }) now === later // => true beta === now // => false ``` - - - - - - - diff --git a/docs/curry/partial.mdx b/docs/curry/partial.mdx index 8bac31b8..9d1ec19f 100644 --- a/docs/curry/partial.mdx +++ b/docs/curry/partial.mdx @@ -4,9 +4,6 @@ group: 'Curry' description: Create a partial a function --- - - - ## Basic usage Create a partial function by providing some -- or all -- of the arguments the given function needs. @@ -20,10 +17,3 @@ const addFive = partial(add, 5) addFive(2) // => 7 ``` - - - - - - - diff --git a/docs/curry/partob.mdx b/docs/curry/partob.mdx index 5c756838..744750a5 100644 --- a/docs/curry/partob.mdx +++ b/docs/curry/partob.mdx @@ -4,9 +4,6 @@ group: 'Curry' description: Create a partob a function --- - - - ## Basic usage Modern javascript destructuring means a lot of developers, libraries, and frameworks are all opting for unary functions that take a single object that contains the arguments. The `_.partob` function let's you partob these unary functions. @@ -20,10 +17,3 @@ const addFive = partob(add, { a: 5 }) addFive({ b: 2 }) // => 7 ``` - - - - - - - diff --git a/docs/curry/proxied.mdx b/docs/curry/proxied.mdx index 7e8d45a3..def656b7 100644 --- a/docs/curry/proxied.mdx +++ b/docs/curry/proxied.mdx @@ -4,9 +4,6 @@ group: 'Curry' description: Create a dynamic proxied a object --- - - - ## Basic usage Javascript's `Proxy` object is powerful but a bit awkward to use. The `_.proxied` function creates the `Proxy` for you and handles calling back to your handler when functions on the `Proxy` are called or properties are accessed. @@ -31,10 +28,3 @@ person.name // => Joe person.size // => 20 person.getLocation() // => here ``` - - - - - - - diff --git a/docs/curry/throttle.mdx b/docs/curry/throttle.mdx index 2e098e6a..0810d11f 100644 --- a/docs/curry/throttle.mdx +++ b/docs/curry/throttle.mdx @@ -4,9 +4,6 @@ group: 'Curry' description: Create a throttled callback function --- - - - ## Basic usage Throttle accepts an options object with an `interval` and a source function to call @@ -14,7 +11,6 @@ when invoked. When the returned function is invoked it will only call the source function if the `interval` milliseconds of time has passed. Otherwise, it will ignore the invocation. - ```ts import { throttle } from 'radash' diff --git a/docs/getting-started.mdx b/docs/getting-started.mdx index ea4acc5b..6afb884c 100644 --- a/docs/getting-started.mdx +++ b/docs/getting-started.mdx @@ -1,15 +1,15 @@ --- -title: "Getting Started" -group: "Getting Started" -description: "Welcome to Radash" +title: 'Getting Started' +group: 'Getting Started' +description: 'Welcome to Radash' --- ## Getting Started ### Welcome to 2020s -Radash is the next library you can't live without. First and foremost, it's powerful. With those -powerful functions, you get strong types and zero dependencies. If you can step out in a bit of +Radash is the next library you can't live without. First and foremost, it's powerful. With those +powerful functions, you get strong types and zero dependencies. If you can step out in a bit of faith and try the functions out, I have no doubt you'll find yourself falling in love. ### Featured Functions @@ -18,6 +18,7 @@ Come, dip your toe in the water. Here are a few functions we can't live without Hopefully, you'll find them useful as well. #### try + The `_.try` function abstracts the logical fork of a try/catch and provides an _error first callback_ reminiscent response. @@ -29,6 +30,7 @@ if (err) { ``` #### range + The `_.range` function returns a generator that can be used for iterating. This means you'll never have to write a `for (let i)` loop again -- and you shouldn't. @@ -43,26 +45,28 @@ for (const i of _.range(10, 20, 2)) { ``` #### select + The `_.select` function takes a mapper and filter function and runs them together for you in a single iteration. No more writing a reduce because you need to map and filter, and you don't want to implement them separately for performance's sake. ```ts const superPoweredGodsFromEgypt = _.select( - gods, - g => ({ ...g, power: g.power * g.power }), + gods, + g => ({ ...g, power: g.power * g.power }), g => g.culture === 'egypt' ) ``` #### defer -The `_.defer` function lets you register functions to run as cleanup while running an async function. It's + +The `_.defer` function lets you register functions to run as cleanup while running an async function. It's like a try/finally, but you can register the finally block at specific times. ```ts -await _.defer(async (defer) => { +await _.defer(async defer => { await api.builds.updateStatus('in-progress') - defer((err) => { + defer(err => { api.builds.updateStatus(err ? 'failed' : 'success') }) @@ -76,11 +80,16 @@ await _.defer(async (defer) => { ``` #### objectify + The `_.objectify` function helps you convert a list to an object in one step. Typically, we either do this in two steps or write a reduce. ```ts -const godsByCulture = _.objectify(gods, g => g.name, g => g.culture) +const godsByCulture = _.objectify( + gods, + g => g.name, + g => g.culture +) ``` ## Love and Hate @@ -95,12 +104,12 @@ and source code that's easy to read and understand. #### Saying No Radash does not provide `_.map` or `_.filter` functions. They were helpful before optional chaining and nullish coalescing. -Now, there really isn't a need. +Now, there really isn't a need. In the last ten years, the JavaScript community as a whole, and the Typescript community specifically, has moved closer to some key values: **deterministic is good, polymorphic is bad, strong types are everything**. A part of Lodash's -charm was that it let you pass different types to a function and get other behavior based on the type. An example +charm was that it let you pass different types to a function and get other behavior based on the type. An example is the `_.map` function, which can take a collection or an object and map over either. Radash doesn't provide that -kind of polymorphic behavior. +kind of polymorphic behavior. Sorry, not sorry. diff --git a/docs/installation.mdx b/docs/installation.mdx index 91c092b9..cb9ebde0 100644 --- a/docs/installation.mdx +++ b/docs/installation.mdx @@ -1,7 +1,7 @@ --- -title: "Installation" -group: "Getting Started" -description: "Getting radash into your project" +title: 'Installation' +group: 'Getting Started' +description: 'Getting radash into your project' --- ## Node diff --git a/docs/object/get.mdx b/docs/object/get.mdx index ddc4df88..3f4b8872 100644 --- a/docs/object/get.mdx +++ b/docs/object/get.mdx @@ -23,7 +23,7 @@ const fish = { ] } -get( fish, 'sizes[0].range[1]' ) // 18 -get( fish, 'sizes.0.range.1' ) // 18 -get( fish, 'foo', 'default' ) // 'default' +get(fish, 'sizes[0].range[1]') // 18 +get(fish, 'sizes.0.range.1') // 18 +get(fish, 'foo', 'default') // 'default' ``` diff --git a/docs/object/listify.mdx b/docs/object/listify.mdx index 08bdc5a3..3fbc69d2 100644 --- a/docs/object/listify.mdx +++ b/docs/object/listify.mdx @@ -4,9 +4,6 @@ description: Convert an object to a list group: Object --- - - - ## Basic usage Given an object and a mapping function, return an array with an item for each entry in the object. @@ -16,19 +13,12 @@ import { listify } from 'radash' const fish = { marlin: { - weight: 105, + weight: 105 }, bass: { - weight: 8, + weight: 8 } } listify(fish, (key, value) => ({ ...value, name: key })) // => [{ name: 'marlin', weight: 105 }, { name: 'bass', weight: 8 }] ``` - - - - - - - diff --git a/docs/object/lowerize.mdx b/docs/object/lowerize.mdx index 66cfd6e6..cdf0dfe6 100644 --- a/docs/object/lowerize.mdx +++ b/docs/object/lowerize.mdx @@ -4,9 +4,6 @@ description: Convert all object keys to lower case group: Object --- - - - ## Basic usage Convert all keys in an object to lower case. Useful to standardize attribute key casing. For example, headers. @@ -23,10 +20,3 @@ lowerize(ra) // => { mode, power } ``` The `_.lowerize` function is a shortcut for `_.mapKeys(obj, k => k.toLowerCase())` - - - - - - - diff --git a/docs/string/snake.mdx b/docs/string/snake.mdx index 5348edd3..e7071ee2 100644 --- a/docs/string/snake.mdx +++ b/docs/string/snake.mdx @@ -20,6 +20,6 @@ snake('green fish blue fish') // => green_fish_blue_fish snake('5green fish 2blue fish') // => 5_green_fish_2_blue_fish snake('5green fish 2blue fish', { - splitOnNumber: false + splitOnNumber: false }) // => 5green_fish_2blue_fish -``` \ No newline at end of file +``` diff --git a/docs/typed/is-date.mdx b/docs/typed/is-date.mdx index db112ae4..0f57fbc5 100644 --- a/docs/typed/is-date.mdx +++ b/docs/typed/is-date.mdx @@ -12,6 +12,6 @@ Determine if a value is a Date. Does not check that the input date is valid, onl import { isDate } from 'radash' isDate(new Date()) // => true -isDate(12) // => false -isDate('hello') // => false +isDate(12) // => false +isDate('hello') // => false ``` diff --git a/docs/typed/is-empty.mdx b/docs/typed/is-empty.mdx index 03d7cc6a..d093ba0f 100644 --- a/docs/typed/is-empty.mdx +++ b/docs/typed/is-empty.mdx @@ -14,6 +14,6 @@ import { isEmpty } from 'radash' isEmpty([]) // => true isEmpty('') // => true -isEmpty('hello') // => false +isEmpty('hello') // => false isEmpty(['hello']) // => false ``` diff --git a/docs/typed/is-equal.mdx b/docs/typed/is-equal.mdx index 880a798c..e3a5d8bc 100644 --- a/docs/typed/is-equal.mdx +++ b/docs/typed/is-equal.mdx @@ -12,8 +12,8 @@ Given two values, returns true if they are equal. import { isEqual } from 'radash' isEqual(null, null) // => true -isEqual([], []) // => true +isEqual([], []) // => true isEqual('hello', 'world') // => false -isEqual(22, 'abc') // => false +isEqual(22, 'abc') // => false ``` diff --git a/docs/typed/is-float.mdx b/docs/typed/is-float.mdx index 69de1dc8..87f6ef15 100644 --- a/docs/typed/is-float.mdx +++ b/docs/typed/is-float.mdx @@ -11,7 +11,7 @@ Pass in a value and get a boolean telling you if the value is a float. ```ts import { isFloat } from 'radash' -isFloat(12.233) // => true -isFloat(12) // => false +isFloat(12.233) // => true +isFloat(12) // => false isFloat('hello') // => false ``` diff --git a/src/tests/string.test.ts b/src/tests/string.test.ts index e87b6e10..664cb3f3 100644 --- a/src/tests/string.test.ts +++ b/src/tests/string.test.ts @@ -170,7 +170,9 @@ describe('string module', () => { expect(_.title('va_va_boom')).toBe('Va Va Boom') expect(_.title('root-hook - ok!')).toBe('Root Hook Ok!') expect(_.title('queryItems')).toBe('Query Items') - expect(_.title('queryAllItems-in_Database')).toBe('Query All Items In Database') + expect(_.title('queryAllItems-in_Database')).toBe( + 'Query All Items In Database' + ) }) test('returns empty string for bad input', () => { expect(_.title(null)).toBe('')