-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
20 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
export const isBrowser = (typeof window !== "undefined"); | ||
export const jQuery: JQueryStatic = isBrowser ? require("jquery") : null; | ||
export const cheerio: cheerio.CheerioAPI = isBrowser ? null : eval('require')("cheerio"); | ||
export const $: cheerio.CheerioAPI = isBrowser ? jQuery as any : cheerio; | ||
const isBrowser = (typeof window !== "undefined"); | ||
const jQuery: JQueryStatic = isBrowser ? require("jquery") : null; | ||
const cheerio: cheerio.CheerioAPI = isBrowser ? null : eval('require')("cheerio"); | ||
|
||
export function createDiv(): cheerio.Cheerio { | ||
return isBrowser ? jQuery("<div/>") as any : cheerio.load("<div/>").root(); | ||
export function createDiv(): [cheerio.Cheerio, cheerio.Root] { | ||
if (isBrowser) | ||
return [jQuery("<div/>"), jQuery] as any; | ||
else { | ||
const $ = cheerio.load("<div/>"); | ||
return [$.root(), $]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters