chore: fmt

This commit is contained in:
orion 2023-10-28 15:49:58 -05:00
parent 2041858fd9
commit c72c268b37
Signed by: orion
GPG Key ID: 6D4165AE4C928719
2 changed files with 14 additions and 11 deletions

View File

@ -1,4 +1,4 @@
import {load} from 'cheerio' import { load } from 'cheerio'
/** @typedef {import('cheerio').Element} Element */ /** @typedef {import('cheerio').Element} Element */
/** @typedef {import('cheerio').Cheerio<Element>} CheerioNode */ /** @typedef {import('cheerio').Cheerio<Element>} CheerioNode */
@ -20,10 +20,13 @@ export const loadImpl = html => () => {
} }
/** @type {(_: CheerioNode) => () => Array<CheerioNode>} */ /** @type {(_: CheerioNode) => () => Array<CheerioNode>} */
export const toArrayImpl = n => () => Array(n.length) .fill(undefined) .map((_, ix) => n.slice(ix, ix + 1)) export const toArrayImpl = n => () =>
Array(n.length)
.fill(undefined)
.map((_, ix) => n.slice(ix, ix + 1))
/** @type {(_: CheerioNode) => () => CheerioNode | null} */ /** @type {(_: CheerioNode) => () => CheerioNode | null} */
export const toNullableImpl = n => () => n.length === 0 ? null : n.first() export const toNullableImpl = n => () => (n.length === 0 ? null : n.first())
/** @type {(_: CheerioNode) => () => CheerioNode} */ /** @type {(_: CheerioNode) => () => CheerioNode} */
export const childrenImpl = n => () => n.children() export const childrenImpl = n => () => n.children()

View File

@ -24,10 +24,10 @@ suites = do
test "attr" do test "attr" do
doc <- liftEffect $ Cheerio.load htmlEx doc <- liftEffect $ Cheerio.load htmlEx
fruits <- liftEffect fruits <- liftEffect
$ liftMaybe (error "ul should have id") $ liftMaybe (error "ul should have id")
=<< Cheerio.attr "id" =<< Cheerio.attr "id"
=<< liftMaybe (error "ul should exist") =<< liftMaybe (error "ul should exist")
=<< Cheerio.findFirst "ul" doc =<< Cheerio.findFirst "ul" doc
Assert.equal "fruits" fruits Assert.equal "fruits" fruits
suite "Traversing" do suite "Traversing" do
@ -40,10 +40,10 @@ suites = do
doc <- liftEffect $ Cheerio.load htmlEx doc <- liftEffect $ Cheerio.load htmlEx
pear <- liftEffect $ liftMaybe (error "pear should exist") =<< Cheerio.findFirst ".pear" doc pear <- liftEffect $ liftMaybe (error "pear should exist") =<< Cheerio.findFirst ".pear" doc
parentId <- liftEffect parentId <- liftEffect
$ liftMaybe (error "parent should have id") $ liftMaybe (error "parent should have id")
=<< Cheerio.attr "id" =<< Cheerio.attr "id"
=<< liftMaybe (error "parent should exist") =<< liftMaybe (error "parent should exist")
=<< Cheerio.parent pear =<< Cheerio.parent pear
Assert.equal "fruits" parentId Assert.equal "fruits" parentId
test "siblings" do test "siblings" do