0.1.5 • Published 4 years ago

@candlefw/url v0.1.5

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

CandleFW URL

version 0.1.2 tests npm deno

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
0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.13

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

5 years ago

0.0.8-0

5 years ago

0.0.7-a

5 years ago

0.0.6-a

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago