Quark #

Modules #

Quark v1.4.0 Documentation

Contents

quark/uri #

cwd()string #

get current working directory

undefined(): string

classicPath(path) #

convert to classic path, for: file:///d:/test/path.js => d:\test\path.js

classicPath(path: string): string

delimiter #

path delimiter

const delimiter: string

resolve(path,partPath?string) #

file:///home/louis/test.txt file:///d:/home/louis/test.txt http://google.com/test.txt return format path

resolve(path: string, partPath?string: any, args: string[]): string

isAbsolute(path) #

Is it an absolute path?

isAbsolute(path: string): boolean

isLocal(path) #

Is it a local path?

isLocal(path: string): boolean

isLocalZip(path) #

isLocalZip(path: string): boolean

isHttp(path) #

isHttp(path: string): boolean

Class: URL #

URL #

URL Processing Tool Type

For example:

// cwd: file:///var/data
// Prints: file:///var/data/index.js
var uri = new URL('index.js');
console.log(uri.href);
// Prints: http://quarks.cc/index.html?args=0
var uri2 = new URL('http://quarks.cc/home/../index.html?args=0')
console.log(uri2.href);
// Prints:
// Error: Parse uri error, Illegal URL
new URL('http://quarks.cc:').href

url.constructor(path?) #

constructor(path?: string)

url.href #

Get the complete URL, including parameters href: "http://xxxx.xxx:81/v1.1.0/quark/path.js?sasasas&asasasa#sdsdsd"

readonly href: string

For example:

// Prints: http://quarks.cc/
console.log(new URL('http://quarks.cc/').href);

url.filename #

Get full path name filename: "/D:/Documents/test.js"

readonly filename: string

For example:

// Prints: /aaa/bbbb/ccc/test.js
console.log(new URL('http://quarks.cc/aaa/bbbb/ccc/test.js').filename);
// Prints: /D:/Documents/test.js
console.log(new URL('file:///D:/Documents/test.js').filename);

url.path #

/a/b/s/test.html?aaaaa=100

readonly path: string

For example:

// Prints: /aaa/bbbb/ccc/test.js?asas=asas
console.log(new URL('http://quarks.cc/aaa/bbbb/ccc/test.js?asas=asas').path);

url.dirname #

Full path dir dirname: "/D:/Documents"

readonly dirname: string

For example:

// Prints: /aaa/bbbb/ccc
console.log(new URL('http://quarks.cc/aaa/bbbb/ccc/test.js').dirname);

Get url query parameters search: "?sasasas&asasasa"

readonly search: string

For example:

// Prints: ?a=A&b=B
console.log(new URL('http://quarks.cc/?a=A&b=B').search);

url.hash #

hash: "#sdsdsd" Get hash parameters

readonly hash: string

For example:

// Prints: #c=C&d=D
console.log(new URL('http://quarks.cc/?a=A&b=B#c=C&d=D').hash);

url.host #

host: "quarks.cc:81" Gets the host name and returns the host name with the port number

readonly host: string

For example:

// Prints: quarks.cc:80
console.log(new URL('http://quarks.cc:81/').host);

url.hostname #

hostname: "quarks.cc" Gets the host name, but does not return the port number

readonly hostname: string

For example:

// Prints: quarks.cc
console.log(new URL('http://quarks.cc:81/').host);

url.origin #

origin: "http://quarks.cc:81" Get the uri origin, protocol+host

readonly origin: string

For example:

// Prints: http://quarks.cc:81
console.log(new URL('http://quarks.cc:81/host/index.html').host);
// Prints: file://
console.log(new URL('file:///var/data/index.html').host);

url.basename #

Get path base name

readonly basename: string

For example:

// Prints: index.html
console.log(new URL('file:///var/data/index.html').basename);

url.extname #

Get path extname

readonly extname: string

For example:

// Prints: .html
console.log(new URL('file:///var/data/index.html').extname);

url.port #

port: "81" Get the host port number. If the port number is not defined in the URL, an empty string is returned.

readonly port: string

For example:

// Prints: 81
console.log(new URL('http://quarks.cc:81').port);
// Prints If there is no port number, an empty string will be returned: ""
console.log(new URL('http://quarks.cc').port);

url.protocol #

Get the protocol type string of the URL, For: 'http:'|'https'|'ftp:'

readonly protocol: string

url.params #

Returns a collection of query parameters as an object, or set

readonly params: Dict<string>

For example:

// Prints:
// {
//   a: "100",
//   b: "test"
// }
console.log(new URL('http://quarks.cc/?a=100&b=test').params);

url.hashParams #

Returns a Hash parameter set as an object, or set

readonly hashParams: Dict<string>

For example:

// Prints:
// {
//   a: "200",
//   b: "300"
// }
console.log(new URL('http://quarks.cc/#a=200&b=300').hashParams);

url.getParam(name) #

Get path param

getParam(name: string): string

For example:

// Prints: ok
console.log(new URL('http://quarks.cc/?args=ok').getParam('args'));

url.setParam(name,value) #

Set the URL query parameter key-value pair and return self

setParam(name: string, value: string): this

url.deleteParam(name) #

Remove URL query parameters by name

deleteParam(name: string): this

url.clearParams() #

Delete all of params in the URL

clearParams(): this

url.getHash(name) #

Get hash param by name

getHash(name: string): string

url.setHash(name,value) #

Set hash param by the key/value

setHash(name: string, value: string): this

url.deleteHash(name) #

Delete hash param by the name

deleteHash(name: string): this

url.clearHashs() #

Delete all of hash params in the URL

clearHashs(): this

url.relative(fromPath) #

Get relative path from fromPath to self

relative(fromPath: string): string

For example:

// Prints: ../A/B/C/test.js
var url = new URL('http://quarks.cc/A/B/C/test.js');
console.log(url.relative('http://quarks.cc/home/'));
// Prints: file:///var/data/A/B/C/test.js
var url2 = new URL('file:///var/data/A/B/C/test.js');
console.log(url2.relative('http://quarks.cc/home/'));

url.toJSON() #

toJSON(): string

default #

default.executable()string #

Get the executable file path

undefined(): string

default.documents(path?) #

Get the documents directory path

documents(path?: string): string

default.temp(path?) #

Get the temporary directory path

temp(path?: string): string

default.resources(path?) #

Get the resources directory path

resources(path?: string): string

default.cwd()string #

Get the current working directory

undefined(): string

default.chdir(path) #

Set the current working directory and return true if successful

chdir(path: string): boolean

default.normalizePath(path,retain_up?) #

Format part path to normalize path

normalizePath(path: string, retain_up?: boolean): string

default.delimiter #

Path delimiter

readonly delimiter: string

default.classicPath(path) #

Restore the path to a path that the operating system can recognize. Generally, you do not need to call this function unless you directly call a Native/C/C++ function that is not provided by Quark

classicPath(path: string): string

For example:

// Prints: /var/data/test.js
console.log(path.normalizePath('file:///var/data/test.js'));

default.resolve(path,partPath?string) #

Format path to standard absolute path

resolve(path: string, partPath?string: any): string

For example:

// Prints: http://quarks.cc/A/C/test.js
console.log(path.resolve('http://quarks.cc/home', "..", "A", "B", "..", "C", "test.js"));
// Prints:
// true
// file:///var/data/aaa/cc/ddd/kk.jpg
console.log(path.chdir('/var/data'));
console.log(path.resolve('aaa/bbb/../cc/.//!<ddd/kk.jpg'));

default.isAbsolute(path) #

Test whether it is an absolute path

isAbsolute(path: string): boolean

For example:

// Prints:
// true
// true
// false
console.log(path.isAbsolute('/var/kk'));
console.log(path.isAbsolute('http://quarks.cc/'));
console.log(path.isAbsolute('index.jsx'));

default.basename(path?) #

full filename

basename(path?: string)

default.dirname(path?) #

Get dirname

dirname(path?: string): string

default.extname(path?) #

Get extname

extname(path?: string): string

default.filename(path?) #

Get filename

filename(path?: string): string

default.path(path?) #

Get path

path(path?: string): string

default.search(path?) #

Get search

search(path?: string): string

default.hash(path?) #

Get hash

hash(path?: string): string

default.host(path?) #

Get host

host(path?: string): string

default.hostname(path?) #

Get hostname

hostname(path?: string): string

default.origin(path?) #

Get origin

origin(path?: string): string

default.port(path?) #

Get port: "81"

port(path?: string): string

default.protocol(path?) #

Get protocol: "http:"

protocol(path?: string): string

default.params(path?) #

Get params

params(path?: string): Dict<string>

default.hashParams(path?) #

Get params

hashParams(path?: string): Dict<string>

default.getParam(name,path?) #

Get path param

getParam(name: string, path?: string): string

default.setParam(name,value,path?) #

Set path param

setParam(name: string, value: string, path?: string): string

default.deleteParam(name,path?) #

Delete path param

deleteParam(name: string, path?: string): string

default.clearParams(path?) #

Delete all of hash params

clearParams(path?: string): string

default.getHash(name,path?) #

Get hash param

getHash(name: string, path?: string): string

default.setHash(name,value,path?) #

Set hash param

setHash(name: string, value: string, path?: string): string

default.deleteHash(name,path?) #

Delete hash param

deleteHash(name: string, path?: string): string

default.clearHashs(path?) #

Delete all of hash params

clearHashs(path?: string): string

default.relative(from,target?) #

Get target path relative to the from path

relative(from: string, target?: string): string