µ.js is the new $
This package is top secret and should not be used by anybody under any circumstances.
- Simplified HTTP request client. request
- Tiny, fast, and elegant implementation of core jQuery designed specifically for the server. cheerio
Examples
/* Initialize jQuery on remote document */let µ =
/* For options, use object passed to request module */
/* From local file */µ
/* From local file synchronously */let $ = µ
/* From a string */let $ = µ // does not even require <html></html> /* <h2>Title of a document</h2><p>Description of a document.</p> */
/* Full document outerHTML*/$
/* Initialize jQuery on remote document synchronously */const $ = µtext // reddit: the front page of the internet
/* Fetch worldnews headlines from Reddit *//* { "title": "Elon Musk's SpaceX Falcon 9 rocket blasts off to deliver human sperm to International Space Station for NASA testsstandard.co.uk", "url": "https://www.standard.co.uk/news/world/spacex-falcon-9-elon-musks-powerful-rocket-blasts-off-to-deliver-human-sperm-to-international-space-a3804171.html"}{ "title": "Russia threatens sanctions over Latvian language in Latvian schoolsbbc.com", "url": "http://www.bbc.com/news/world-europe-43626368"}{ "title": "Robert Mueller’s Russia probe reportedly rolled a witness, George Nader, who confirmed that Blackwater founder Erik Prince did indeed attempt to set up a secret backchannel between Trump and Russia in January 2017uproxx.com", "url": "https://uproxx.com/news/russian-met-erik-prince-backchannel-link-putin/"} ... more*/
Update: 30 october 2019
Added additional method sync for synchronous initialization. See example.
Update: 1 april 2018
Now includes 3 additional methods: fromFile, fromFileSync and fromString.
Update: 4 september 2018
Resolved instance of jQuery (cheerio) now includes reference to HTTP response, which in turn includes a reference to the HTTP request. This can be used for stuff like reading header information (Content-type, cache-control, ...) and detect redirect(s).
let url = 'http://example.com'