Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

urlmodule

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

urlmodule - npm Package Compare versions

Comparing version
0.0.1
to
0.0.2
+89
lib/URLAssembler.js
import { Assembler } from 'esmodule'
const { URL } = window
const { getTargetOf } = Assembler
/**
* @see https://url.spec.whatwg.org/#url
*/
export class URLAssembler extends Assembler {
/**
* @returns {string}
*/
toString() {
return this.url.toString()
}
/**
* @param {*} searchParams {{}}
*/
set searchParams(searchParams) {
const _searchParams = this.searchParams
Object.keys(searchParams).forEach(key => {
const value = searchParams[key]
if(Array.isArray(value)) {
value.forEach(item => _searchParams.append(key, item))
}
else _searchParams.set(key, value)
})
}
/**
* @returns {URLSearchParams}
*/
get searchParams() {
return this.url.searchParams
}
/**
* @returns {URL}
*/
get url() {
return getTargetOf(this)
}
/**
* @override
* @returns {URL}
*/
static create() {
const { url, base } = this
return base?
new this.interface(url, base) :
new this.interface(url)
}
/**
* @abstract
*/
static get url() {}
/**
* @abstract
*/
static get base() {}
/**
* @override
* @returns {string}
*/
static get targetPropertyName() {
return 'url'
}
/**
* @override
* @returns {string}
*/
static get defaultPropertyName() {
return 'href'
}
/**
* @override
* @returns {interface} URL
*/
static get interface() {
return URL
}
}
+1
-1

@@ -7,2 +7,2 @@ /**

*/
export * from './url'
export * from './URLAssembler'
{
"name": "urlmodule",
"version": "0.0.1",
"version": "0.0.2",
"description": "URL assembler library",

@@ -45,6 +45,6 @@ "files": [

"dependencies": {
"esmodule": "github:aristov/esmodule"
"esmodule": "^0.1.1"
},
"devDependencies": {
"htmlmodule": "github:aristov/htmlmodule",
"htmlmodule": "^0.6.1",
"webpack": "^4.17.2",

@@ -51,0 +51,0 @@ "webpack-command": "^0.4.1"

import { Assembler } from 'esmodule'
const { URL } = window
const { getTargetOf } = Assembler
/**
* @see https://url.spec.whatwg.org/#url
*/
export class URLAssembler extends Assembler {
/**
* @returns {string}
*/
toString() {
return this.url.toString()
}
/**
* @param {*} searchParams {{}}
*/
set searchParams(searchParams) {
const _searchParams = this.searchParams
Object.keys(searchParams).forEach(key => {
_searchParams.set(key, searchParams[key])
})
}
/**
* @returns {URLSearchParams}
*/
get searchParams() {
return this.url.searchParams
}
/**
* @returns {URL}
*/
get url() {
return getTargetOf(this)
}
/**
* @override
* @returns {URL}
*/
static create() {
return new this.interface(this.url, this.base)
}
/**
* @abstract
*/
static get url() {}
/**
* @abstract
*/
static get base() {}
/**
* @override
* @returns {string}
*/
static get targetPropertyName() {
return 'url'
}
/**
* @override
* @returns {string}
*/
static get defaultPropertyName() {
return 'href'
}
/**
* @override
* @returns {interface} URL
*/
static get interface() {
return URL
}
}