From 03835ee89db55c959bd1a6c9d576d2f152eea8b8 Mon Sep 17 00:00:00 2001 From: Orion Kindel Date: Sat, 4 Nov 2023 13:38:47 -0500 Subject: [PATCH] fix: is --- src/Cheerio.js | 3 +++ src/Cheerio.purs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/Cheerio.js b/src/Cheerio.js index d723f8a..0b1ce75 100644 --- a/src/Cheerio.js +++ b/src/Cheerio.js @@ -54,3 +54,6 @@ export const textImpl = n => () => n.text() || '' /** @type {(_1: string) => (_2: CheerioNode) => () => CheerioNode} */ export const findImpl = s => n => () => n.find(s) + +/** @type {(_1: string) => (_2: CheerioNode) => () => boolean} */ +export const isImpl = s => n => () => n.is(s) diff --git a/src/Cheerio.purs b/src/Cheerio.purs index 1185982..2bc5795 100644 --- a/src/Cheerio.purs +++ b/src/Cheerio.purs @@ -28,6 +28,7 @@ foreign import cssImpl :: CheerioNode -> Effect (Object String) foreign import htmlImpl :: CheerioNode -> Effect String foreign import textImpl :: CheerioNode -> Effect String +foreign import isImpl :: String -> CheerioNode -> Effect Boolean foreign import findImpl :: String -> CheerioNode -> Effect CheerioNode load :: String -> Effect CheerioNode @@ -57,6 +58,9 @@ html = htmlImpl text :: CheerioNode -> Effect String text = textImpl +is :: String -> CheerioNode -> Effect Boolean +is s = isImpl s + find :: String -> CheerioNode -> Effect (Array (CheerioNode)) find s = toArrayImpl <=< findImpl s