@candlefw/url v0.1.5
CandleFW URL
cfw.url is a root CandleFW TypeScript library used to parse URI/URL strings and send and receive information from these resources. It has an isometric API, allowing it to be used in both server environments and in browser. It provides the core resource fetching functionality found within all CandleFW libraries that require such services.
As a root CFW library, it has zero dependencies aside from built-in JavaScript and NodeJS objects. Its simple interface allows for easy integration within larger libraries and products, providing reliable URL parsing, resource retrieval, and data transmission functions.
USAGE
note: This script uses ES2015 module syntax. It is recommended you use NodeJS version 14.3.0 or later for maximum compatibility.
Install
NPM
npm install --save @candlefw/url
YARN
yarn add @candlefw/url
TL/DR
NodeJS
import URL from "@candlefw/url";
//Activate server side features. Not needed on browser.
URL.server();
const
// Parse any valid URL
resource : typeof URL = new URL("https://user@cdn.host.tld:8080/?test#test"),
// URL is split into component parts.
{ protocol, user, pwd, host, port, path, query, hash } = resource;
// Data can be assigned to the query section
resource.setData({
user_name: "gilbert",
comments: "likes grapes",
received_port: port
})
console.log(resource.query)
// => ?user_name=gilbert&comments=likes%20grapes&port=80
// URL instances can be used to send and receive data based on the
// the current state of the stored URL.
resource.fetchJSON().then(object_data : any =>{
console.log(object_data.reply);
someResource.consumeData(object_data);
}).catch(err=>{
console.error(err)
})
ITTY BITTY NITTY GRITTY
CandleFW Dependents
- cfw.hydrocarbon
- cfw.wick
- cfw.flame
- cfw.lantern
- cfw.css
- cfw.test
- cfw.conflagrate
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago