mirror of
https://github.com/dzeiocom/libs.git
synced 2025-04-22 10:52:11 +00:00
Merge branch 'master' into make-functions-use-null-23
This commit is contained in:
commit
b885cf66b7
@ -6,10 +6,19 @@ indent_size = 4
|
|||||||
charset = utf-8
|
charset = utf-8
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
max_line_length = 120
|
||||||
|
end_of_line = lf
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
[*.{yaml|yml}]
|
[*.{yaml|yml}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
|
||||||
|
[*.{cpp,h,ino}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
1
.github/workflows/node.js.yml
vendored
1
.github/workflows/node.js.yml
vendored
@ -51,7 +51,6 @@ jobs:
|
|||||||
-Dsonar.tests=packages/easy-sitemap/__tests__,packages/object-util/__tests__,packages/url-manager/__tests__
|
-Dsonar.tests=packages/easy-sitemap/__tests__,packages/object-util/__tests__,packages/url-manager/__tests__
|
||||||
-Dsonar.test.inclusions=packages/**/*.test.ts
|
-Dsonar.test.inclusions=packages/**/*.test.ts
|
||||||
-Dsonar.sourceEncoding=UTF-8
|
-Dsonar.sourceEncoding=UTF-8
|
||||||
-Dsonar.verbose=true
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
lerna-debug.log
|
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
dist
|
dist
|
||||||
.cache
|
.cache
|
||||||
|
@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
Collection of libraries for differents usages
|
Collection of libraries for differents usages
|
||||||
|
|
||||||
[](https://codecov.io/gh/dzeiocom/libs)
|
[](https://sonarcloud.io/project/overview?id=dzeiocom_libs)
|
||||||
|
|
||||||
## Libraries
|
## Libraries
|
||||||
|
|
||||||
|
### Config
|
||||||
|
|
||||||
|
Holder for my configurations used in most of my other repositories
|
||||||
|
|
||||||
### DOM Manager
|
### DOM Manager
|
||||||
|
|
||||||
Library to manage the browser DOM easier
|
Library to manage the browser DOM easier
|
||||||
|
9701
package-lock.json
generated
9701
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.0.2",
|
"@types/jest": "^27.0.2",
|
||||||
"jest": "^27.2.3",
|
"jest": "^27.2.4",
|
||||||
"jest-sonar-reporter": "^2.0.0",
|
"jest-sonar-reporter": "^2.0.0",
|
||||||
"ts-jest": "^27.0.5",
|
"ts-jest": "^27.0.5",
|
||||||
"ts-node": "^10.2.1",
|
"ts-node": "^10.2.1",
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
"error",
|
"error",
|
||||||
"always"
|
"always"
|
||||||
],
|
],
|
||||||
"complexity": "off",
|
|
||||||
"constructor-super": "error",
|
"constructor-super": "error",
|
||||||
"curly": "error",
|
"curly": "error",
|
||||||
"dot-notation": "error",
|
"dot-notation": "error",
|
||||||
@ -45,11 +44,7 @@
|
|||||||
"warn",
|
"warn",
|
||||||
{
|
{
|
||||||
"exceptions": [
|
"exceptions": [
|
||||||
"_",
|
"_"
|
||||||
"a",
|
|
||||||
"b",
|
|
||||||
"c",
|
|
||||||
"p"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -61,7 +56,6 @@
|
|||||||
"SwitchCase": 1
|
"SwitchCase": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"init-declration": "off",
|
|
||||||
"linebreak-style": [
|
"linebreak-style": [
|
||||||
"error",
|
"error",
|
||||||
"unix"
|
"unix"
|
||||||
@ -73,7 +67,7 @@
|
|||||||
"max-len": [
|
"max-len": [
|
||||||
"warn",
|
"warn",
|
||||||
{
|
{
|
||||||
"code": 200
|
"code": 120
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"new-parens": "error",
|
"new-parens": "error",
|
||||||
@ -115,7 +109,6 @@
|
|||||||
"no-import-assign": "error",
|
"no-import-assign": "error",
|
||||||
"no-inner-declarations": "error",
|
"no-inner-declarations": "error",
|
||||||
"no-invalid-regexp": "error",
|
"no-invalid-regexp": "error",
|
||||||
"no-invalid-this": "off",
|
|
||||||
"no-irregular-whitespace": "error",
|
"no-irregular-whitespace": "error",
|
||||||
"no-label-var": "error",
|
"no-label-var": "error",
|
||||||
"no-loss-of-precision": "error",
|
"no-loss-of-precision": "error",
|
||||||
@ -126,7 +119,6 @@
|
|||||||
"no-promise-executor-return": "error",
|
"no-promise-executor-return": "error",
|
||||||
"no-prototype-builtins": "error",
|
"no-prototype-builtins": "error",
|
||||||
"no-regex-spaces": "error",
|
"no-regex-spaces": "error",
|
||||||
"no-restricted-globals": "off",
|
|
||||||
"no-setter-return": "error",
|
"no-setter-return": "error",
|
||||||
"no-shadow": [
|
"no-shadow": [
|
||||||
"error",
|
"error",
|
||||||
@ -158,7 +150,7 @@
|
|||||||
"no-unused-labels": "error",
|
"no-unused-labels": "error",
|
||||||
"no-unused-vars": "warn",
|
"no-unused-vars": "warn",
|
||||||
"no-var": "error",
|
"no-var": "error",
|
||||||
"object-shorthand": "error",
|
"object-shorthand": ["warn", "methods"],
|
||||||
"one-var": [
|
"one-var": [
|
||||||
"error",
|
"error",
|
||||||
"never"
|
"never"
|
||||||
@ -191,6 +183,8 @@
|
|||||||
],
|
],
|
||||||
"spaced-comment": "error",
|
"spaced-comment": "error",
|
||||||
"use-isnan": "error",
|
"use-isnan": "error",
|
||||||
"valid-typeof": "warn"
|
"valid-typeof": "warn",
|
||||||
|
"complexity": ["warn", 5],
|
||||||
|
"max-depth": ["warn", 2]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,14 @@
|
|||||||
"default": "generic"
|
"default": "generic"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"@typescript-eslint/ban-types": "error",
|
"@typescript-eslint/ban-types": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"types": {
|
||||||
|
"{}": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"@typescript-eslint/consistent-type-assertions": "error",
|
"@typescript-eslint/consistent-type-assertions": "error",
|
||||||
"@typescript-eslint/consistent-type-definitions": "error",
|
"@typescript-eslint/consistent-type-definitions": "error",
|
||||||
"@typescript-eslint/explicit-member-accessibility": [
|
"@typescript-eslint/explicit-member-accessibility": [
|
||||||
@ -48,8 +55,6 @@
|
|||||||
"accessibility": "explicit"
|
"accessibility": "explicit"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
||||||
"@typescript-eslint/interface-name-prefix": "off",
|
|
||||||
"@typescript-eslint/member-delimiter-style": [
|
"@typescript-eslint/member-delimiter-style": [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
@ -74,7 +79,6 @@
|
|||||||
"ignoreJSX": "all"
|
"ignoreJSX": "all"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"@typescript-eslint/no-inferrable-types": "off",
|
|
||||||
"@typescript-eslint/no-misused-new": "error",
|
"@typescript-eslint/no-misused-new": "error",
|
||||||
"@typescript-eslint/no-namespace": "error",
|
"@typescript-eslint/no-namespace": "error",
|
||||||
"@typescript-eslint/no-parameter-properties": "off",
|
"@typescript-eslint/no-parameter-properties": "off",
|
||||||
@ -85,7 +89,6 @@
|
|||||||
"allowTernary": true
|
"allowTernary": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"@typescript-eslint/no-use-before-define": "off",
|
|
||||||
"@typescript-eslint/prefer-for-of": "error",
|
"@typescript-eslint/prefer-for-of": "error",
|
||||||
"@typescript-eslint/prefer-function-type": "error",
|
"@typescript-eslint/prefer-function-type": "error",
|
||||||
"@typescript-eslint/prefer-namespace-keyword": "error",
|
"@typescript-eslint/prefer-namespace-keyword": "error",
|
||||||
|
@ -1,57 +1,55 @@
|
|||||||
import { NextConfig, defaultConfig } from 'next/dist/server/config-shared'
|
import { objectLoop } from '@dzeio/object-util'
|
||||||
import { PHASE_DEVELOPMENT_SERVER } from 'next/constants'
|
import { PHASE_DEVELOPMENT_SERVER } from 'next/constants'
|
||||||
|
import { defaultConfig, NextConfig } from 'next/dist/server/config-shared'
|
||||||
// @ts-expect-error next-pre-css has no typing available
|
// @ts-expect-error next-pre-css has no typing available
|
||||||
import preCSS from 'next-pre-css'
|
import preCSS from 'next-pre-css'
|
||||||
|
|
||||||
|
interface Options {
|
||||||
|
/**
|
||||||
|
* Hold the lit of additionnal hosts the frontend might connect to
|
||||||
|
*/
|
||||||
|
hosts?: Partial<Record<
|
||||||
|
'style'| 'script' | 'prefetch' | 'img' | 'font',
|
||||||
|
Array<string>
|
||||||
|
>>
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a default NextJS hardened configuration with experimental features enabled and headers preset
|
* Return a default NextJS hardened configuration with experimental features enabled and headers preset
|
||||||
*/
|
*/
|
||||||
export const config = (additionnalHost: string): typeof defaultConfig & NextConfig => ({
|
export const config = (options?: Options): typeof defaultConfig & NextConfig => ({
|
||||||
// Experimentals
|
|
||||||
experimental: {
|
|
||||||
plugins: true,
|
|
||||||
profiling: process.env.NODE_ENV === 'developpment',
|
|
||||||
isrFlushToDisk: true,
|
|
||||||
|
|
||||||
// Bugged
|
|
||||||
// https://github.com/vercel/next.js/issues/18913
|
|
||||||
// reactRoot: true,
|
|
||||||
workerThreads: true,
|
|
||||||
|
|
||||||
pageEnv: true,
|
|
||||||
optimizeImages: true,
|
|
||||||
optimizeCss: true,
|
|
||||||
|
|
||||||
scrollRestoration: true,
|
|
||||||
|
|
||||||
stats: process.env.NODE_ENV === 'developpment',
|
|
||||||
externalDir: true,
|
|
||||||
conformance: true,
|
|
||||||
disableOptimizedLoading: false,
|
|
||||||
gzipSize: process.env.NODE_ENV === 'developpment',
|
|
||||||
craCompat: false,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
excludeDefaultMomentLocales: true,
|
excludeDefaultMomentLocales: true,
|
||||||
trailingSlash: false,
|
trailingSlash: false,
|
||||||
cleanDistDir: true,
|
cleanDistDir: true,
|
||||||
generateEtags: true,
|
generateEtags: true,
|
||||||
compress: false,
|
compress: false,
|
||||||
// Non experimental config
|
|
||||||
// target: 'serverless',
|
|
||||||
poweredByHeader: false,
|
poweredByHeader: false,
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
|
|
||||||
// Futures
|
crossOrigin: 'anonymous',
|
||||||
future: {
|
swcMinify: true,
|
||||||
strictPostcssConfiguration: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
// Headers and rewrites
|
// Headers and rewrites
|
||||||
async headers() {
|
async headers() {
|
||||||
|
const hosts = options?.hosts ?? {}
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
if (!hosts.script) {
|
||||||
|
hosts.script = []
|
||||||
|
}
|
||||||
|
hosts.script.push('\'unsafe-eval\'')
|
||||||
|
}
|
||||||
|
|
||||||
|
let hostlist: Array<string> = []
|
||||||
|
|
||||||
|
objectLoop(hosts, (it) => {
|
||||||
|
hostlist.push(...it)
|
||||||
|
})
|
||||||
|
|
||||||
|
hostlist = hostlist.filter((it, index, arr) => arr.indexOf(it) === index)
|
||||||
|
|
||||||
// CSS no CSP, x-xss-protection
|
// CSS no CSP, x-xss-protection
|
||||||
const CSP = {
|
const CSP = {
|
||||||
key: 'Content-Security-Policy',
|
key: 'Content-Security-Policy',
|
||||||
@ -62,11 +60,11 @@ export const config = (additionnalHost: string): typeof defaultConfig & NextConf
|
|||||||
"form-action 'self'; " +
|
"form-action 'self'; " +
|
||||||
"manifest-src 'self'; " +
|
"manifest-src 'self'; " +
|
||||||
"prefetch-src 'self'; " +
|
"prefetch-src 'self'; " +
|
||||||
`script-src 'self' 'unsafe-inline' 'unsafe-eval' ${additionnalHost}; ` +
|
`script-src 'self' 'unsafe-inline' ${hosts?.script?.join(' ') ?? ''}; ` +
|
||||||
"style-src 'self' 'unsafe-inline'; " +
|
`style-src 'self' 'unsafe-inline' ${hosts?.style?.join(' ') ?? ''}; ` +
|
||||||
"img-src data: 'self'; " +
|
`img-src data: 'self' ${hosts?.img?.join(' ') ?? ''}; ` +
|
||||||
"font-src 'self'; " +
|
`font-src 'self' ${hosts?.font?.join(' ') ?? ''}; ` +
|
||||||
`connect-src 'self' ${additionnalHost}; ` +
|
`connect-src 'self' ${hostlist.filter((it) => !it.startsWith('unsafe')).join(' ')}; ` +
|
||||||
"base-uri 'self';"
|
"base-uri 'self';"
|
||||||
}
|
}
|
||||||
const XXssProtection = {
|
const XXssProtection = {
|
||||||
@ -83,7 +81,7 @@ export const config = (additionnalHost: string): typeof defaultConfig & NextConf
|
|||||||
value: 'nosniff'
|
value: 'nosniff'
|
||||||
}, {
|
}, {
|
||||||
key: 'Referrer-Policy',
|
key: 'Referrer-Policy',
|
||||||
value: 'strict-origin-when-cross-origin'
|
value: 'no-referer'
|
||||||
}, {
|
}, {
|
||||||
key: 'Permissions-Policy',
|
key: 'Permissions-Policy',
|
||||||
value: 'geolocation=(), microphone=(), interest-cohort=()'
|
value: 'geolocation=(), microphone=(), interest-cohort=()'
|
||||||
|
2012
packages/config/package-lock.json
generated
Normal file
2012
packages/config/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dzeio/config",
|
"name": "@dzeio/config",
|
||||||
"version": "1.1.4",
|
"version": "1.1.12",
|
||||||
"description": "global configuration files for programming",
|
"description": "global configuration files for programming",
|
||||||
"author": "Avior",
|
"author": "Avior",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -10,13 +10,15 @@
|
|||||||
"directory": "packages/config"
|
"directory": "packages/config"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^16.10.1",
|
"@dzeio/object-util": "^1",
|
||||||
"next": "^11.1.2"
|
"@types/node": "^18",
|
||||||
|
"next": "^12"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@typescript-eslint/parser": "^4.28.2",
|
"@dzeio/object-util": ">=1.4.2",
|
||||||
"next": "^11.1.2",
|
"@typescript-eslint/parser": ">=5.18.0",
|
||||||
"next-pre-css": "^1.0.0"
|
"next": ">=12.1.0",
|
||||||
|
"next-pre-css": ">=1.0.0"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"next": {
|
"next": {
|
||||||
@ -32,5 +34,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "tsc",
|
"prepublishOnly": "tsc",
|
||||||
"build": "tsc --noEmit"
|
"build": "tsc --noEmit"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"package.json": "^2.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,3 +4,4 @@ node_modules
|
|||||||
.npmignore
|
.npmignore
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
Listener.ts
|
Listener.ts
|
||||||
|
!dist
|
||||||
|
@ -6,10 +6,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [1.0.3] - 2022-11-17
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Package not including code
|
||||||
|
|
||||||
|
## [1.0.2] - 2022-11-17
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Event `all` not being sent
|
||||||
|
- Warning when too much event are set
|
||||||
|
|
||||||
|
## [1.0.1] - 2021-02-08
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [1.0.0] - 2020-11-23
|
## [1.0.0] - 2020-11-23
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Implementation of custom Listener for cross platform listener
|
- Implementation of custom Listener for cross platform listener
|
||||||
|
|
||||||
|
[1.0.3]: https://github.com/dzeiocom/libs/releases/tag/%40dzeio%2Flistener%401.0.3
|
||||||
|
[1.0.2]: https://github.com/dzeiocom/libs/releases/tag/%40dzeio%2Flistener%401.0.2
|
||||||
|
[1.0.1]: https://github.com/dzeiocom/libs/releases/tag/%40dzeio%2Flistener%401.0.1
|
||||||
[1.0.0]: https://github.com/dzeiocom/libs/releases/tag/%40dzeio%2Flistener%401.0.0
|
[1.0.0]: https://github.com/dzeiocom/libs/releases/tag/%40dzeio%2Flistener%401.0.0
|
||||||
|
@ -69,7 +69,7 @@ export default abstract class Listener<
|
|||||||
(this.handlers[event] as Array<T[typeof event]>).splice(index, 1)
|
(this.handlers[event] as Array<T[typeof event]>).splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-expect-error Meta Listener
|
||||||
this.emit('removeListener', event, listener)
|
this.emit('removeListener', event, listener)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@ -122,6 +122,10 @@ export default abstract class Listener<
|
|||||||
* @param ev the variables to send
|
* @param ev the variables to send
|
||||||
*/
|
*/
|
||||||
public emit(event: keyof T, ...ev: Parameters<T[typeof event]>) {
|
public emit(event: keyof T, ...ev: Parameters<T[typeof event]>) {
|
||||||
|
if (event !== 'all') {
|
||||||
|
// @ts-expect-error Meta Listener
|
||||||
|
this.emit('all', event, ...ev)
|
||||||
|
}
|
||||||
const listeners = this.listeners(event)
|
const listeners = this.listeners(event)
|
||||||
listeners.forEach((fn) => fn(...ev))
|
listeners.forEach((fn) => fn(...ev))
|
||||||
return listeners.length > 0
|
return listeners.length > 0
|
||||||
@ -175,7 +179,7 @@ export default abstract class Listener<
|
|||||||
}
|
}
|
||||||
|
|
||||||
private internalAdd(push: boolean, event: keyof T, listener: T[typeof event]) {
|
private internalAdd(push: boolean, event: keyof T, listener: T[typeof event]) {
|
||||||
// @ts-ignore
|
// @ts-expect-error Meta Listener
|
||||||
this.emit('newListener', event, listener)
|
this.emit('newListener', event, listener)
|
||||||
const item = this.handlers[event]
|
const item = this.handlers[event]
|
||||||
if (!item) {
|
if (!item) {
|
||||||
@ -189,7 +193,7 @@ export default abstract class Listener<
|
|||||||
}
|
}
|
||||||
const listenerCount = this.listenerCount(event)
|
const listenerCount = this.listenerCount(event)
|
||||||
if (listenerCount > this.getMaxListeners()) {
|
if (listenerCount > this.getMaxListeners()) {
|
||||||
console.warn(`MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${this.getMaxListeners()} userStateChanged listeners added to [FireAuth]. Use emitter.setMaxListeners() to increase limitWarning: more than are in the event ${event}! (${listenerCount})`)
|
console.warn(`MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${this.getMaxListeners()} listeners recommended while there is ${listenerCount} listeners. Use emitter.setMaxListeners() to increase limit`)
|
||||||
}
|
}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dzeio/listener",
|
"name": "@dzeio/listener",
|
||||||
"version": "1.0.1",
|
"version": "1.0.3",
|
||||||
"description": "A NodeJS Listener implementation",
|
"description": "A NodeJS Listener implementation",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -12,7 +12,7 @@
|
|||||||
"main": "./dist/Listener.js",
|
"main": "./dist/Listener.js",
|
||||||
"types": "./dist/Listener.d.ts",
|
"types": "./dist/Listener.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "yarn build",
|
"prepublishOnly": "npm run build",
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
|
extends: "../config/eslint/typescript.json",
|
||||||
|
root: true,
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"project": __dirname + "/tsconfig.json"
|
"project": `${dirname}/tsconfig.json`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,59 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [1.4.5] - 2022-12-08
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Typescript returning errors when object can contains undefined
|
||||||
|
|
||||||
|
## [1.4.4] - 2022-12-08
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Export being borked
|
||||||
|
|
||||||
|
## [1.4.3] - 2022-12-08
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 6be80cb2e135ac98c8a156f0c2bc93dc4cc170f6 Missing type declaration for some callback functions
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- f515091ac58f309106dd06a86e9c6a011f90623d More clear comment
|
||||||
|
|
||||||
|
## [1.4.2] - 2021-09-29
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 9f608a52fc32447b6f839415f90cba85d4b1ca35 `Object.freeze` error with `objectClone`
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 7ce7daf75184249da62c521bcab75263d324f0b1 Updated Jest to 27
|
||||||
|
|
||||||
|
## [1.4.1] - 2021-09-29
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- b7b604e11f8fe8654de963822080269066de9c41 Used objectLoop instead of basic loops
|
||||||
|
- b7b604e11f8fe8654de963822080269066de9c41 Add JS modules support
|
||||||
|
- 3d02a29bc5a059f8e5f28640144870311dc3d449 Moved back to NPM from Yarn
|
||||||
|
|
||||||
|
## [1.4.0] - 2021-09-28
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- cb97ded195963c1a9ec17f0085b3d195b344a91e new `objectOmit` function that allows you to remove items from an object
|
||||||
|
|
||||||
|
## [1.3.0] - 2021-09-21
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 4efb33c0cb243ddf26fb144ea6c6d5c3714ea6ae new `objectClean` cleanup `null`/`undefined` from an object (more in options)
|
||||||
|
- 4efb33c0cb243ddf26fb144ea6c6d5c3714ea6ae new `isObject` function that allows verify is your variable is an object
|
||||||
|
|
||||||
## [1.2.0] - 2021-05-21
|
## [1.2.0] - 2021-05-21
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
/// <reference types="jest" />
|
/// <reference types="jest" />
|
||||||
|
|
||||||
import { objectSize, objectMap, objectSort, objectEqual, objectKeys, objectSet, objectLoop, objectClone, objectValues, objectClean, isObject, objectOmit } from '../src/ObjectUtil'
|
import { isObject, objectClean, objectClone, objectEqual, objectKeys, objectLoop, objectMap, objectOmit, objectRemap, objectSet, objectSize, objectSort, objectValues } from '../src/ObjectUtil'
|
||||||
|
|
||||||
describe('Throw if parameter is not an object', () => {
|
describe('Throw if parameter is not an object', () => {
|
||||||
it('should works', () => {
|
it('should works', () => {
|
||||||
// @ts-ignore
|
|
||||||
expect(objectKeys).toThrow()
|
expect(objectKeys).toThrow()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -19,6 +18,16 @@ describe('Object Map tests', () => {
|
|||||||
return [index, value]
|
return [index, value]
|
||||||
})).toEqual([['pouet', 'first'],['toto','second']])
|
})).toEqual([['pouet', 'first'],['toto','second']])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should works on arrays', () => {
|
||||||
|
const obj = [
|
||||||
|
'first',
|
||||||
|
'second'
|
||||||
|
]
|
||||||
|
expect(objectMap(obj, (value, index) => {
|
||||||
|
return [index, value]
|
||||||
|
})).toEqual([[0, 'first'],[1, 'second']])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Object Loop Tests', () => {
|
describe('Object Loop Tests', () => {
|
||||||
@ -36,6 +45,52 @@ describe('Object Loop Tests', () => {
|
|||||||
throw "it should not come here"
|
throw "it should not come here"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should work on arrays', () => {
|
||||||
|
const obj = [
|
||||||
|
true,
|
||||||
|
'object-util'
|
||||||
|
]
|
||||||
|
objectLoop(obj, (value, key) => {
|
||||||
|
if (key === 0) {
|
||||||
|
expect(value).toBe(true)
|
||||||
|
} else if (key === 1) {
|
||||||
|
expect(value).toBe('object-util')
|
||||||
|
} else {
|
||||||
|
throw "it should not come here"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should return false', () => {
|
||||||
|
const obj = {
|
||||||
|
pouet: true
|
||||||
|
}
|
||||||
|
expect(objectLoop(obj, () => {
|
||||||
|
return false
|
||||||
|
})).toBe(false)
|
||||||
|
// TO BE EXPECTED in MAJOR change
|
||||||
|
// expect(objectLoop(obj, () => {
|
||||||
|
// return undefined
|
||||||
|
// })).toBe(false)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should return true', () => {
|
||||||
|
const obj = {
|
||||||
|
pouet: true
|
||||||
|
}
|
||||||
|
expect(objectLoop(obj, () => {
|
||||||
|
return true
|
||||||
|
})).toBe(true)
|
||||||
|
// TO BE EXPECTED until major change
|
||||||
|
expect(objectLoop(obj, () => {
|
||||||
|
return undefined
|
||||||
|
})).toBe(true)
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -47,20 +102,28 @@ describe('Object To Array Tests', () => {
|
|||||||
}
|
}
|
||||||
expect(objectValues(obj)).toEqual(['first', 'second'])
|
expect(objectValues(obj)).toEqual(['first', 'second'])
|
||||||
})
|
})
|
||||||
|
// it('shoud work on arrays', () => {
|
||||||
|
// const obj = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
|
// expect(objectValues(obj)).toEqual(obj)
|
||||||
|
// })
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Object Keys Tests', () => {
|
describe('Object Keys Tests', () => {
|
||||||
it('Should Works', () => {
|
it('Should work on objects', () => {
|
||||||
const obj = {
|
const obj = {
|
||||||
pouet: 'first',
|
pouet: 'first',
|
||||||
toto: 'second'
|
toto: 'second'
|
||||||
}
|
}
|
||||||
expect(objectKeys(obj)).toEqual(['pouet', 'toto'])
|
expect(objectKeys(obj)).toEqual(['pouet', 'toto'])
|
||||||
})
|
})
|
||||||
|
it('shoud work on arrays', () => {
|
||||||
|
const obj = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
|
expect(objectKeys(obj)).toEqual(obj)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Object Size Tests', () => {
|
describe('Object Size Tests', () => {
|
||||||
it('shoud return length of the object', () => {
|
it('shoud return length of an object', () => {
|
||||||
const obj = {
|
const obj = {
|
||||||
index0: true,
|
index0: true,
|
||||||
index1: false,
|
index1: false,
|
||||||
@ -76,6 +139,10 @@ describe('Object Size Tests', () => {
|
|||||||
}
|
}
|
||||||
expect(objectSize(obj)).toBe(11)
|
expect(objectSize(obj)).toBe(11)
|
||||||
})
|
})
|
||||||
|
it('shoud return length of an array', () => {
|
||||||
|
const obj = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
|
expect(objectSize(obj)).toBe(10)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Object sort Tests', () => {
|
describe('Object sort Tests', () => {
|
||||||
@ -89,6 +156,10 @@ describe('Object sort Tests', () => {
|
|||||||
b: 'first'
|
b: 'first'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
// it('should sort an array (yes stupid)', () => {
|
||||||
|
// const arr = [2, 1, 0]
|
||||||
|
// expect(objectSort(arr, (a, b) => a - b)).toEqual([0, 1, 2])
|
||||||
|
// })
|
||||||
it('should sort by the specified key', () => {
|
it('should sort by the specified key', () => {
|
||||||
const obj = {
|
const obj = {
|
||||||
b: 'first',
|
b: 'first',
|
||||||
@ -143,6 +214,17 @@ describe('Object Clone Tests', () => {
|
|||||||
expect(clone).not.toEqual(obj)
|
expect(clone).not.toEqual(obj)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should deeply clone the object when option is set', () => {
|
||||||
|
const obj = {
|
||||||
|
pouet: {is: 'first'},
|
||||||
|
toto: 'second'
|
||||||
|
}
|
||||||
|
const clone = objectClone(obj, {deep: true})
|
||||||
|
expect(clone).toEqual(obj)
|
||||||
|
clone.toto = 'third'
|
||||||
|
expect(clone).not.toEqual(obj)
|
||||||
|
})
|
||||||
|
|
||||||
it('should clone an Array', () => {
|
it('should clone an Array', () => {
|
||||||
const obj = ['one', 'two']
|
const obj = ['one', 'two']
|
||||||
const clone = objectClone(obj)
|
const clone = objectClone(obj)
|
||||||
@ -242,6 +324,9 @@ describe('Object Equal Test', () => {
|
|||||||
a: [10, {b: 'c'}], d: '1', e: 2, f: true, g: null, h: undefined
|
a: [10, {b: 'c'}], d: '1', e: 2, f: true, g: null, h: undefined
|
||||||
})).toBe(true)
|
})).toBe(true)
|
||||||
})
|
})
|
||||||
|
it('should handle arrays with empty elements', () => {
|
||||||
|
expect(objectEqual([,true], [,true])).toBe(true)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Object Clean Tests', () => {
|
describe('Object Clean Tests', () => {
|
||||||
@ -250,6 +335,22 @@ describe('Object Clean Tests', () => {
|
|||||||
objectClean(obj)
|
objectClean(obj)
|
||||||
expect(obj).toEqual({a: '', b: null})
|
expect(obj).toEqual({a: '', b: null})
|
||||||
})
|
})
|
||||||
|
it('should clean undefined when told to', () => {
|
||||||
|
const obj = {a: '', b: null, c: undefined}
|
||||||
|
objectClean(obj, {cleanUndefined: true})
|
||||||
|
expect(obj).toEqual({a: '', b: null})
|
||||||
|
})
|
||||||
|
it('should clean deeply when told to', () => {
|
||||||
|
const obj = {a: '', b: null, c: {aa: undefined}}
|
||||||
|
objectClean(obj, {deep: true})
|
||||||
|
expect(obj).toEqual({a: '', b: null, c: {}})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should clean falsy values when told to', () => {
|
||||||
|
const obj = {obj: 'util', a: '', b: null, c: {aa: undefined}}
|
||||||
|
objectClean(obj, {cleanFalsy: true})
|
||||||
|
expect(obj).toEqual({obj: 'util', c: {}})
|
||||||
|
})
|
||||||
it('should not clean when options.cleanUndefined is false', () => {
|
it('should not clean when options.cleanUndefined is false', () => {
|
||||||
const obj2 = {a: '', b: null, c: undefined}
|
const obj2 = {a: '', b: null, c: undefined}
|
||||||
objectClean(obj2, {cleanUndefined: false})
|
objectClean(obj2, {cleanUndefined: false})
|
||||||
@ -285,6 +386,10 @@ describe('Object Omit Tests', () => {
|
|||||||
const obj = {a: 'a', b: 'c', c: 'b'}
|
const obj = {a: 'a', b: 'c', c: 'b'}
|
||||||
expect(objectOmit(Object.freeze(obj), 'b', 'd')).toEqual({a: 'a', c: 'b'})
|
expect(objectOmit(Object.freeze(obj), 'b', 'd')).toEqual({a: 'a', c: 'b'})
|
||||||
})
|
})
|
||||||
|
it('should work with an array', () => {
|
||||||
|
const obj = [1, 2, 3, 4]
|
||||||
|
expect(objectOmit(obj, 1, 3)).toEqual([1,undefined,3,undefined])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Is Object Tests', () => {
|
describe('Is Object Tests', () => {
|
||||||
@ -306,4 +411,32 @@ describe('Is Object Tests', () => {
|
|||||||
it('object is an "object"', () => {
|
it('object is an "object"', () => {
|
||||||
expect(isObject({})).toBe(true)
|
expect(isObject({})).toBe(true)
|
||||||
})
|
})
|
||||||
|
it('array is an object', () => expect(isObject([])).toBe(true))
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
describe('object remap tests', () => {
|
||||||
|
it('should works on objects', () => {
|
||||||
|
expect(objectRemap({a: "pouet"}, (value, key) => {
|
||||||
|
return {key: key + 'a', value}
|
||||||
|
})).toEqual({aa: "pouet"})
|
||||||
|
})
|
||||||
|
it('should works on arrays', () => {
|
||||||
|
const pouet: [string] = ['pokemon']
|
||||||
|
expect(objectRemap(pouet, (value, key: number) => {
|
||||||
|
return {key: key + 2, value}
|
||||||
|
})).toEqual({2: "pokemon"})
|
||||||
|
})
|
||||||
|
it('should replace value', () => {
|
||||||
|
expect(objectRemap({a: 'a', b: 'b'}, (value) => {
|
||||||
|
return {key: 'b', value}
|
||||||
|
})).toEqual({b: 'b'})
|
||||||
|
})
|
||||||
|
it('should throw an error in strict mode', () => {
|
||||||
|
expect(() => {
|
||||||
|
objectRemap({a: 'a', b: 'b'}, (value) => {
|
||||||
|
return {key: 'b', value}
|
||||||
|
}, {strict: true})
|
||||||
|
}).toThrow()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
412
packages/object-util/package-lock.json
generated
Normal file
412
packages/object-util/package-lock.json
generated
Normal file
@ -0,0 +1,412 @@
|
|||||||
|
{
|
||||||
|
"name": "@dzeio/object-util",
|
||||||
|
"version": "1.5.0",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "@dzeio/object-util",
|
||||||
|
"version": "1.5.0",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"esbuild": "^0.13.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/esbuild": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==",
|
||||||
|
"dev": true,
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"bin": {
|
||||||
|
"esbuild": "bin/esbuild"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"esbuild-android-arm64": "0.13.15",
|
||||||
|
"esbuild-darwin-64": "0.13.15",
|
||||||
|
"esbuild-darwin-arm64": "0.13.15",
|
||||||
|
"esbuild-freebsd-64": "0.13.15",
|
||||||
|
"esbuild-freebsd-arm64": "0.13.15",
|
||||||
|
"esbuild-linux-32": "0.13.15",
|
||||||
|
"esbuild-linux-64": "0.13.15",
|
||||||
|
"esbuild-linux-arm": "0.13.15",
|
||||||
|
"esbuild-linux-arm64": "0.13.15",
|
||||||
|
"esbuild-linux-mips64le": "0.13.15",
|
||||||
|
"esbuild-linux-ppc64le": "0.13.15",
|
||||||
|
"esbuild-netbsd-64": "0.13.15",
|
||||||
|
"esbuild-openbsd-64": "0.13.15",
|
||||||
|
"esbuild-sunos-64": "0.13.15",
|
||||||
|
"esbuild-windows-32": "0.13.15",
|
||||||
|
"esbuild-windows-64": "0.13.15",
|
||||||
|
"esbuild-windows-arm64": "0.13.15"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-android-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-m602nft/XXeO8YQPUDVoHfjyRVPdPgjyyXOxZ44MK/agewFFkPa8tUo6lAzSWh5Ui5PB4KR9UIFTSBKh/RrCmg==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"android"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-darwin-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-darwin-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-freebsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"freebsd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-freebsd-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"freebsd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-32": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==",
|
||||||
|
"cpu": [
|
||||||
|
"ia32"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-arm": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-mips64le": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==",
|
||||||
|
"cpu": [
|
||||||
|
"mips64el"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-ppc64le": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==",
|
||||||
|
"cpu": [
|
||||||
|
"ppc64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-netbsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-3+yE9emwoevLMyvu+iR3rsa+Xwhie7ZEHMGDQ6dkqP/ndFzRHkobHUKTe+NCApSqG5ce2z4rFu+NX/UHnxlh3w==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"netbsd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-openbsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"openbsd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-sunos-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"sunos"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-windows-32": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==",
|
||||||
|
"cpu": [
|
||||||
|
"ia32"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-windows-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-windows-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"esbuild": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"esbuild-android-arm64": "0.13.15",
|
||||||
|
"esbuild-darwin-64": "0.13.15",
|
||||||
|
"esbuild-darwin-arm64": "0.13.15",
|
||||||
|
"esbuild-freebsd-64": "0.13.15",
|
||||||
|
"esbuild-freebsd-arm64": "0.13.15",
|
||||||
|
"esbuild-linux-32": "0.13.15",
|
||||||
|
"esbuild-linux-64": "0.13.15",
|
||||||
|
"esbuild-linux-arm": "0.13.15",
|
||||||
|
"esbuild-linux-arm64": "0.13.15",
|
||||||
|
"esbuild-linux-mips64le": "0.13.15",
|
||||||
|
"esbuild-linux-ppc64le": "0.13.15",
|
||||||
|
"esbuild-netbsd-64": "0.13.15",
|
||||||
|
"esbuild-openbsd-64": "0.13.15",
|
||||||
|
"esbuild-sunos-64": "0.13.15",
|
||||||
|
"esbuild-windows-32": "0.13.15",
|
||||||
|
"esbuild-windows-64": "0.13.15",
|
||||||
|
"esbuild-windows-arm64": "0.13.15"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"esbuild-android-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-m602nft/XXeO8YQPUDVoHfjyRVPdPgjyyXOxZ44MK/agewFFkPa8tUo6lAzSWh5Ui5PB4KR9UIFTSBKh/RrCmg==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-darwin-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-darwin-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-freebsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-freebsd-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-32": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-arm": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-mips64le": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-ppc64le": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-netbsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-3+yE9emwoevLMyvu+iR3rsa+Xwhie7ZEHMGDQ6dkqP/ndFzRHkobHUKTe+NCApSqG5ce2z4rFu+NX/UHnxlh3w==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-openbsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-sunos-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-windows-32": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-windows-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-windows-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dzeio/object-util",
|
"name": "@dzeio/object-util",
|
||||||
"version": "1.4.2",
|
"version": "1.5.0",
|
||||||
"description": "Utility functions to manipulate an object",
|
"description": "Utility functions to manipulate an object",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -15,11 +15,27 @@
|
|||||||
"types": "./dist/types/ObjectUtil.d.ts",
|
"types": "./dist/types/ObjectUtil.d.ts",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"esbuild": "^0.13.2"
|
"@types/jest": "^29",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5",
|
||||||
|
"@typescript-eslint/parser": "^5",
|
||||||
|
"esbuild": "^0.16.2",
|
||||||
|
"eslint": "^8",
|
||||||
|
"jest": "^29",
|
||||||
|
"jest-sonar-reporter": "^2",
|
||||||
|
"ts-jest": "^29",
|
||||||
|
"ts-node": "^10",
|
||||||
|
"typescript": "^4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "npm run build",
|
"prepublishOnly": "npm run build",
|
||||||
"build": "esbuild src/index.ts --outfile=dist/browser.js --minify --bundle --target=es6 && tsc && tsc --project tsconfig.esm.json",
|
"build": "esbuild src/index.ts --outfile=dist/browser.js --minify --bundle --target=es6 && tsc && tsc --project tsconfig.esm.json",
|
||||||
"test": "jest --coverage"
|
"test": "jest --coverage",
|
||||||
}
|
"lint": "eslint src"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"README.md",
|
||||||
|
"package.json",
|
||||||
|
"CHANGELOG.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
|
export type BasicObjectKeys = string | number | symbol
|
||||||
|
export type BasicObject<K extends BasicObjectKeys = BasicObjectKeys, V = any> = { [P in K]?: V }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remap an object to an array through a function
|
* Remap an object to an array through a function
|
||||||
*
|
*
|
||||||
* (Same as Array.map)
|
* (Same as Array.map but for objects)
|
||||||
|
*
|
||||||
* @param obj the object to remap
|
* @param obj the object to remap
|
||||||
* @param fn the function to run for each key: value pairs
|
* @param fn the function to run for each key: value pairs
|
||||||
|
* @returns {Array} a new array filled with the object fn callback
|
||||||
*/
|
*/
|
||||||
export function objectMap<T = any, J = any>(
|
export function objectMap<T = any, J = any, K extends BasicObjectKeys = BasicObjectKeys>(
|
||||||
obj: Record<string, T>,
|
obj: BasicObject<K, T>,
|
||||||
fn: (value: T, key: string, index: number) => J
|
fn: (value: T, key: K, index: number) => J
|
||||||
): Array<J> {
|
): Array<J> {
|
||||||
mustBeObject(obj)
|
mustBeObject(obj)
|
||||||
const list: Array<J> = []
|
const list: Array<J> = []
|
||||||
@ -18,19 +23,53 @@ export function objectMap<T = any, J = any>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loop through the object
|
* a more advanced map function that transform an object back into another object
|
||||||
* @param obj the object to loop through
|
*
|
||||||
* @param fn the function to run for each childs
|
* note: if multiple key are the same only the last value will be set unless options.strict is enabled
|
||||||
|
*
|
||||||
|
* note2: for an array you will have to add manual typing to the `key` like this: `key: number`
|
||||||
|
*
|
||||||
|
* warn: the value is not a clone
|
||||||
|
*
|
||||||
|
* @param obj the object to remap (it will not be changed)
|
||||||
|
* @param fn the function to run through
|
||||||
|
* @param options optionnal options that change how the function works
|
||||||
|
* @param options.strict (default: false) enabling this will throw an error if the same key is set twice
|
||||||
|
* @returns a not deeply cloned object with it's key/values set from the [fn] function
|
||||||
*/
|
*/
|
||||||
export function objectLoop<T = any>(
|
export function objectRemap<T = any, J extends BasicObject = BasicObject, K extends BasicObjectKeys = BasicObjectKeys>(
|
||||||
obj: Record<string, T>,
|
obj: BasicObject<K, T>,
|
||||||
fn: (value: T, key: string, index: number) => boolean | void
|
fn: (value: T, key: K, index: number) => {key: keyof J, value: J[typeof key]},
|
||||||
|
options?: {strict?: boolean}
|
||||||
|
): J {
|
||||||
|
mustBeObject(obj)
|
||||||
|
const clone: J = {} as any
|
||||||
|
objectLoop(obj, (item, oldKey, index) => {
|
||||||
|
const { key, value } = fn(item, oldKey, index)
|
||||||
|
if (options?.strict && key in clone) {
|
||||||
|
throw new Error('objectRemap strict mode active, you can\'t remap the same key twice')
|
||||||
|
}
|
||||||
|
clone[key] = value
|
||||||
|
})
|
||||||
|
return clone
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loop through the object
|
||||||
|
*
|
||||||
|
* @param obj the object to loop through
|
||||||
|
* @param fn the function to run for each childs if the function return `false` it will stop
|
||||||
|
* @returns {boolean} return if the loop finished or ended early
|
||||||
|
*/
|
||||||
|
export function objectLoop<T = any, K extends BasicObjectKeys = BasicObjectKeys>(
|
||||||
|
obj: BasicObject<K, T>,
|
||||||
|
fn: (value: T, key: K, index: number) => boolean | void
|
||||||
): boolean {
|
): boolean {
|
||||||
mustBeObject(obj)
|
mustBeObject(obj)
|
||||||
const keys = objectKeys(obj)
|
const keys = objectKeys(obj)
|
||||||
for (let index = 0; index < keys.length; index++) {
|
for (let index = 0; index < keys.length; index++) {
|
||||||
const key = keys[index]
|
const key = keys[index]
|
||||||
const stop = fn(obj[key], key, index)
|
const stop = fn(obj[key] as T, key as K, index)
|
||||||
if (stop === false) {
|
if (stop === false) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -40,46 +79,59 @@ export function objectLoop<T = any>(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform an object to an array of its values
|
* Transform an object to an array of its values
|
||||||
|
*
|
||||||
* @param obj the object to transform
|
* @param obj the object to transform
|
||||||
|
* @returns {Array} an array containing the object's values
|
||||||
*/
|
*/
|
||||||
export function objectValues<T = any>(obj: Record<string, T>): Array<T> {
|
export function objectValues<T = any>(obj: BasicObject<BasicObjectKeys, T>): Array<T> {
|
||||||
mustBeObject(obj)
|
mustBeObject(obj)
|
||||||
return Object.values(obj)
|
return Object.values(obj) as Array<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use `objectValues`
|
* @deprecated use `objectValues`
|
||||||
*/
|
*/
|
||||||
export function objectToArray<T = any>(obj: Record<string, T>): Array<T> {
|
export function objectToArray<T = any>(obj: BasicObject<BasicObjectKeys, T>): Array<T> {
|
||||||
mustBeObject(obj)
|
mustBeObject(obj)
|
||||||
return objectValues(obj)
|
return objectValues(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the keys of the object
|
* return the keys of the object
|
||||||
|
*
|
||||||
* @param obj the object
|
* @param obj the object
|
||||||
|
* @returns {Array} an array containing the object's keys
|
||||||
*/
|
*/
|
||||||
export function objectKeys(obj: Record<string, any>): Array<string> {
|
export function objectKeys<K extends BasicObjectKeys = BasicObjectKeys>(obj: BasicObject<K>): Array<K> {
|
||||||
mustBeObject(obj)
|
mustBeObject(obj)
|
||||||
return Object.keys(obj)
|
|
||||||
|
// Handle arrays
|
||||||
|
if (Array.isArray(obj)) {
|
||||||
|
return Array.from(obj.keys()) as Array<K>
|
||||||
|
}
|
||||||
|
return Object.keys(obj) as Array<K>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the length of an object
|
* return the length of an object
|
||||||
|
*
|
||||||
* @param obj the object
|
* @param obj the object
|
||||||
|
* @returns {number} the object's size
|
||||||
*/
|
*/
|
||||||
export function objectSize(obj: Record<string, any>): number {
|
export function objectSize(obj: BasicObject): number {
|
||||||
return objectKeys(obj).length
|
return objectKeys(obj).length
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort an object by its keys
|
* Sort an object by its keys
|
||||||
*
|
*
|
||||||
* Same as Array.sort
|
* Same as Array.sort but for objects
|
||||||
|
*
|
||||||
* @param obj the object to sort
|
* @param obj the object to sort
|
||||||
* @param fn (Optionnal) the function to run to sort
|
* @param fn (Optionnal) the function to run to sort
|
||||||
|
* @returns a new object with the keys sorted using the fn
|
||||||
*/
|
*/
|
||||||
export function objectSort<T extends Record<string, any> = Record<string, any>>(
|
export function objectSort<T extends BasicObject>(
|
||||||
obj: T,
|
obj: T,
|
||||||
fn?: Array<keyof T> | ((a: keyof T, b: keyof T) => number)
|
fn?: Array<keyof T> | ((a: keyof T, b: keyof T) => number)
|
||||||
): T {
|
): T {
|
||||||
@ -87,7 +139,7 @@ export function objectSort<T extends Record<string, any> = Record<string, any>>(
|
|||||||
const ordered: any = {}
|
const ordered: any = {}
|
||||||
let sortedKeys: Array<keyof T> = []
|
let sortedKeys: Array<keyof T> = []
|
||||||
if (Array.isArray(fn)) {
|
if (Array.isArray(fn)) {
|
||||||
sortedKeys = fn.concat(objectKeys(obj).filter((k) => !fn.includes(k)))
|
sortedKeys = fn.concat(objectKeys(obj).filter((key) => !fn.includes(key)))
|
||||||
} else {
|
} else {
|
||||||
sortedKeys = objectKeys(obj).sort(fn)
|
sortedKeys = objectKeys(obj).sort(fn)
|
||||||
}
|
}
|
||||||
@ -100,25 +152,26 @@ export function objectSort<T extends Record<string, any> = Record<string, any>>(
|
|||||||
/**
|
/**
|
||||||
* @deprecated use `objectClone`
|
* @deprecated use `objectClone`
|
||||||
*/
|
*/
|
||||||
export function cloneObject<T = Record<string, any>>(obj: T): T {
|
export function cloneObject<T extends BasicObject>(obj: T): T {
|
||||||
return objectClone(obj)
|
return objectClone(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deeply clone an object
|
* Deeply clone an object
|
||||||
|
*
|
||||||
* @param obj the object to clone
|
* @param obj the object to clone
|
||||||
|
* @param options Cloning options
|
||||||
|
* @param options.deep (Default: true) deeply clone the object
|
||||||
* @returns the clone of the object
|
* @returns the clone of the object
|
||||||
*/
|
*/
|
||||||
export function objectClone<T = Record<string, any>>(obj: T, options?: {deep?: boolean}): T {
|
export function objectClone<T extends BasicObject>(obj: T, options?: {deep?: boolean}): T {
|
||||||
mustBeObject(obj)
|
mustBeObject(obj)
|
||||||
if (Array.isArray(obj)) {
|
if (Array.isArray(obj)) {
|
||||||
const arr: Array<any> = []
|
const arr: Array<any> = []
|
||||||
for (const item of obj) {
|
for (const item of obj) {
|
||||||
if (isObject(item)) {
|
arr.push(
|
||||||
arr.push(objectClone(item))
|
isObject(item) ? objectClone(item) : item
|
||||||
} else {
|
)
|
||||||
arr.push(item)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return arr as unknown as T
|
return arr as unknown as T
|
||||||
}
|
}
|
||||||
@ -136,20 +189,22 @@ export function objectClone<T = Record<string, any>>(obj: T, options?: {deep?: b
|
|||||||
/**
|
/**
|
||||||
* deeply set the value at the path given
|
* deeply set the value at the path given
|
||||||
*
|
*
|
||||||
* (Create sub object/array if not made)
|
* (Create sub object/array if not made depending on path type (number = Array, string = Object))
|
||||||
|
*
|
||||||
|
* _NOTE: it is way quicker to use `obj[path][path]... = value` when possible_
|
||||||
*
|
*
|
||||||
* _NOTE: it is way quicker to use obj[path][path]... = value_
|
|
||||||
* @param obj the object to set the value
|
* @param obj the object to set the value
|
||||||
* @param path the path
|
* @param path the path
|
||||||
* @param value the value
|
* @param value the value
|
||||||
*/
|
*/
|
||||||
export function objectSet(obj: Record<string, any>, path: Array<string | number>, value: any): void {
|
export function objectSet(obj: BasicObject, path: Array<BasicObjectKeys>, value: any): void {
|
||||||
mustBeObject(obj)
|
mustBeObject(obj)
|
||||||
let pointer = obj
|
let pointer = obj
|
||||||
for (let index = 0; index < path.length; index++) {
|
for (let index = 0; index < path.length; index++) {
|
||||||
const key = path[index]
|
const key = path[index]
|
||||||
if ((!Object.prototype.hasOwnProperty.call(pointer, key)) && (index+1) < path.length) {
|
const nextIndex = index + 1
|
||||||
const key1 = path[index + 1]
|
if (!Object.prototype.hasOwnProperty.call(pointer, key) && nextIndex < path.length) {
|
||||||
|
const key1 = path[nextIndex]
|
||||||
if (typeof key1 === 'number') {
|
if (typeof key1 === 'number') {
|
||||||
pointer[key] = []
|
pointer[key] = []
|
||||||
} else {
|
} else {
|
||||||
@ -158,13 +213,14 @@ export function objectSet(obj: Record<string, any>, path: Array<string | number>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if last index
|
// if last index
|
||||||
if ((index+1) === path.length) {
|
if (nextIndex === path.length) {
|
||||||
pointer[key] = value
|
pointer[key] = value
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
delete pointer[key]
|
delete pointer[key]
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// move pointer to new key
|
// move pointer to new key
|
||||||
pointer = pointer[key]
|
pointer = pointer[key]
|
||||||
}
|
}
|
||||||
@ -172,20 +228,22 @@ export function objectSet(obj: Record<string, any>, path: Array<string | number>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* deeply compare objects and return if they are equal or not
|
* deeply compare objects and return if they are equal or not
|
||||||
* @param x the first object
|
*
|
||||||
* @param y the second object
|
* @param first the first object
|
||||||
|
* @param second the second object
|
||||||
|
* @returns {boolean} a boolean representing the equality of the two objects
|
||||||
*/
|
*/
|
||||||
export function objectEqual(x: Record<string, any>, y: Record<string, any>): boolean {
|
export function objectEqual(first: BasicObject, second: BasicObject): boolean {
|
||||||
mustBeObject(x)
|
mustBeObject(first)
|
||||||
mustBeObject(y)
|
mustBeObject(second)
|
||||||
if (objectSize(x) !== objectSize(y)) {
|
if (objectSize(first) !== objectSize(second)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const res = objectLoop(x, (item, key) => {
|
const res = objectLoop(first, (item, key) => {
|
||||||
if (!(key in y)) {
|
if (!(key in second) && key in first) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const item2 = y[key]
|
const item2 = second[key]
|
||||||
if (item === null && item2 === null) {
|
if (item === null && item2 === null) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -198,36 +256,43 @@ export function objectEqual(x: Record<string, any>, y: Record<string, any>): boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deeply clean an object from having {key: undefined}
|
* Deeply clean an object from having `undefined`,`null` and/or flasy values (options to enable)
|
||||||
|
*
|
||||||
* @param obj the object to clean
|
* @param obj the object to clean
|
||||||
|
* @param options cleanup options
|
||||||
* @param {boolean?} options.cleanUndefined (default: true) clean undefined from the object
|
* @param {boolean?} options.cleanUndefined (default: true) clean undefined from the object
|
||||||
* @param {boolean?} options.cleanNull clean null frrom the object
|
* @param {boolean?} options.cleanFalsy (default: false) clean falsy values (including undefined and null) from the object see https://developer.mozilla.org/en-US/docs/Glossary/Falsy
|
||||||
|
* @param {boolean?} options.cleanNull (default: false) clean null from the object
|
||||||
* @param {boolean?} options.deep (default: true) deeply clean the object
|
* @param {boolean?} options.deep (default: true) deeply clean the object
|
||||||
*/
|
*/
|
||||||
export function objectClean(obj: Record<string, any>, options?: {cleanUndefined?: boolean, cleanNull?: boolean, deep?: boolean}): void {
|
export function objectClean(obj: BasicObject, options?: {cleanUndefined?: boolean, cleanNull?: boolean, cleanFalsy?: boolean, deep?: boolean}): void {
|
||||||
mustBeObject(obj)
|
mustBeObject(obj)
|
||||||
objectLoop(obj, (item, key) => {
|
objectLoop(obj, (item, key) => {
|
||||||
if ((typeof options?.cleanUndefined === 'undefined' || options?.cleanUndefined) && item === undefined) {
|
if ((typeof options?.cleanUndefined === 'undefined' || options.cleanUndefined) && item === undefined) {
|
||||||
delete obj[key]
|
delete obj[key] // clean undefined values
|
||||||
|
} else if (options?.cleanFalsy && !obj[key]) {
|
||||||
|
delete obj[key] // clean falsy values
|
||||||
|
} else if (options?.cleanNull && item === null) {
|
||||||
|
delete obj[key] // clean null values
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.cleanNull && item === null) {
|
// deeply clean the object
|
||||||
delete obj[key]
|
if ((typeof options?.deep === 'undefined' || options.deep) && isObject(item)) {
|
||||||
}
|
objectClean(item, options)
|
||||||
|
|
||||||
if ((typeof options?.deep === 'undefined' || options?.deep) && isObject(item)) {
|
|
||||||
return objectClean(item, options)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clone the object (not deeply) and emit some keys from cloning
|
* return a new object containing only not the keys defined
|
||||||
|
*
|
||||||
|
* note: clone is not deep
|
||||||
|
*
|
||||||
* @param obj the object to clone
|
* @param obj the object to clone
|
||||||
* @param keys the keys to emit
|
* @param keys the keys to emit
|
||||||
* @returns the cloned object
|
* @returns the cloned object
|
||||||
*/
|
*/
|
||||||
export function objectOmit<T extends Record<string, any> = Record<string, any>>(obj: T, ...keys: Array<string>): T {
|
export function objectOmit<T extends BasicObject>(obj: T, ...keys: Array<string | number>): T {
|
||||||
const cloned = objectClone(obj, {deep: false})
|
const cloned = objectClone(obj, {deep: false})
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
if (key in cloned) {
|
if (key in cloned) {
|
||||||
@ -239,30 +304,33 @@ export function objectOmit<T extends Record<string, any> = Record<string, any>>(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* return if an item is an object
|
* return if an item is an object
|
||||||
|
*
|
||||||
* @param item the item to check
|
* @param item the item to check
|
||||||
* @returns {boolean} the item is an object
|
* @returns {boolean} the item is an object
|
||||||
*/
|
*/
|
||||||
export function isObject(item: any): item is Record<any, any> {
|
export function isObject(item: any): item is BasicObject {
|
||||||
return typeof item === 'object' && item !== null
|
return typeof item === 'object' && item !== null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strict check for an object
|
* Strict check for an object
|
||||||
*
|
*
|
||||||
* @internal
|
* throw an error is the item is not an item
|
||||||
|
*
|
||||||
* @param item the item to check
|
* @param item the item to check
|
||||||
* @returns {boolean} throw an error is the item is not an item
|
* @returns {boolean} true is the item is an object, else throw an error
|
||||||
*/
|
*/
|
||||||
function mustBeObject(item: any): item is Record<any, any> {
|
export function mustBeObject(item: any): item is BasicObject {
|
||||||
if (isObject(item)) {
|
if (isObject(item)) {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Input is not an object!")
|
throw new Error('Input is not an object!')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
objectMap,
|
objectMap,
|
||||||
|
objectRemap,
|
||||||
objectLoop,
|
objectLoop,
|
||||||
objectToArray,
|
objectToArray,
|
||||||
objectKeys,
|
objectKeys,
|
||||||
@ -274,5 +342,6 @@ export default {
|
|||||||
objectEqual,
|
objectEqual,
|
||||||
objectClean,
|
objectClean,
|
||||||
objectOmit,
|
objectOmit,
|
||||||
isObject
|
isObject,
|
||||||
|
mustBeObject
|
||||||
}
|
}
|
||||||
|
425
packages/url-manager/package-lock.json
generated
Normal file
425
packages/url-manager/package-lock.json
generated
Normal file
@ -0,0 +1,425 @@
|
|||||||
|
{
|
||||||
|
"name": "@dzeio/url-manager",
|
||||||
|
"version": "1.0.7",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "@dzeio/url-manager",
|
||||||
|
"version": "1.0.7",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@dzeio/object-util": "^1.4.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"esbuild": "^0.13.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@dzeio/object-util": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@dzeio/object-util/-/object-util-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-dqBQo9aUNUi9XVAMJl3dZgA+wKAQgehdvmMX+04X29ovWCYcWuXvq+8HEzckQXMPQ/xYw+D/fV2S96QYaHzX1g=="
|
||||||
|
},
|
||||||
|
"node_modules/esbuild": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==",
|
||||||
|
"dev": true,
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"bin": {
|
||||||
|
"esbuild": "bin/esbuild"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"esbuild-android-arm64": "0.13.15",
|
||||||
|
"esbuild-darwin-64": "0.13.15",
|
||||||
|
"esbuild-darwin-arm64": "0.13.15",
|
||||||
|
"esbuild-freebsd-64": "0.13.15",
|
||||||
|
"esbuild-freebsd-arm64": "0.13.15",
|
||||||
|
"esbuild-linux-32": "0.13.15",
|
||||||
|
"esbuild-linux-64": "0.13.15",
|
||||||
|
"esbuild-linux-arm": "0.13.15",
|
||||||
|
"esbuild-linux-arm64": "0.13.15",
|
||||||
|
"esbuild-linux-mips64le": "0.13.15",
|
||||||
|
"esbuild-linux-ppc64le": "0.13.15",
|
||||||
|
"esbuild-netbsd-64": "0.13.15",
|
||||||
|
"esbuild-openbsd-64": "0.13.15",
|
||||||
|
"esbuild-sunos-64": "0.13.15",
|
||||||
|
"esbuild-windows-32": "0.13.15",
|
||||||
|
"esbuild-windows-64": "0.13.15",
|
||||||
|
"esbuild-windows-arm64": "0.13.15"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-android-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-m602nft/XXeO8YQPUDVoHfjyRVPdPgjyyXOxZ44MK/agewFFkPa8tUo6lAzSWh5Ui5PB4KR9UIFTSBKh/RrCmg==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"android"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-darwin-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-darwin-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-freebsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"freebsd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-freebsd-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"freebsd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-32": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==",
|
||||||
|
"cpu": [
|
||||||
|
"ia32"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-arm": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-mips64le": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==",
|
||||||
|
"cpu": [
|
||||||
|
"mips64el"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-linux-ppc64le": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==",
|
||||||
|
"cpu": [
|
||||||
|
"ppc64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-netbsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-3+yE9emwoevLMyvu+iR3rsa+Xwhie7ZEHMGDQ6dkqP/ndFzRHkobHUKTe+NCApSqG5ce2z4rFu+NX/UHnxlh3w==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"netbsd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-openbsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"openbsd"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-sunos-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"sunos"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-windows-32": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==",
|
||||||
|
"cpu": [
|
||||||
|
"ia32"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-windows-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/esbuild-windows-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@dzeio/object-util": {
|
||||||
|
"version": "1.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@dzeio/object-util/-/object-util-1.4.2.tgz",
|
||||||
|
"integrity": "sha512-dqBQo9aUNUi9XVAMJl3dZgA+wKAQgehdvmMX+04X29ovWCYcWuXvq+8HEzckQXMPQ/xYw+D/fV2S96QYaHzX1g=="
|
||||||
|
},
|
||||||
|
"esbuild": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"esbuild-android-arm64": "0.13.15",
|
||||||
|
"esbuild-darwin-64": "0.13.15",
|
||||||
|
"esbuild-darwin-arm64": "0.13.15",
|
||||||
|
"esbuild-freebsd-64": "0.13.15",
|
||||||
|
"esbuild-freebsd-arm64": "0.13.15",
|
||||||
|
"esbuild-linux-32": "0.13.15",
|
||||||
|
"esbuild-linux-64": "0.13.15",
|
||||||
|
"esbuild-linux-arm": "0.13.15",
|
||||||
|
"esbuild-linux-arm64": "0.13.15",
|
||||||
|
"esbuild-linux-mips64le": "0.13.15",
|
||||||
|
"esbuild-linux-ppc64le": "0.13.15",
|
||||||
|
"esbuild-netbsd-64": "0.13.15",
|
||||||
|
"esbuild-openbsd-64": "0.13.15",
|
||||||
|
"esbuild-sunos-64": "0.13.15",
|
||||||
|
"esbuild-windows-32": "0.13.15",
|
||||||
|
"esbuild-windows-64": "0.13.15",
|
||||||
|
"esbuild-windows-arm64": "0.13.15"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"esbuild-android-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-m602nft/XXeO8YQPUDVoHfjyRVPdPgjyyXOxZ44MK/agewFFkPa8tUo6lAzSWh5Ui5PB4KR9UIFTSBKh/RrCmg==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-darwin-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-darwin-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-freebsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-freebsd-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-32": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-arm": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-mips64le": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-linux-ppc64le": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-netbsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-3+yE9emwoevLMyvu+iR3rsa+Xwhie7ZEHMGDQ6dkqP/ndFzRHkobHUKTe+NCApSqG5ce2z4rFu+NX/UHnxlh3w==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-openbsd-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-sunos-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-windows-32": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-windows-64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"esbuild-windows-arm64": {
|
||||||
|
"version": "0.13.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.15.tgz",
|
||||||
|
"integrity": "sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==",
|
||||||
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dzeio/url-manager",
|
"name": "@dzeio/url-manager",
|
||||||
"version": "1.0.6",
|
"version": "1.0.9",
|
||||||
"description": "A simple to use yet complete Urls parser and serializer",
|
"description": "A simple to use yet complete Urls parser and serializer",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -12,7 +12,10 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "./dist/cjs/URLManager.js",
|
"main": "./dist/cjs/URLManager.js",
|
||||||
"module": "./dist/esm/URLManager.js",
|
"module": "./dist/esm/URLManager.js",
|
||||||
"types": "./dist/URLManager.d.ts",
|
"types": "./dist/types/URLManager.d.ts",
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"url",
|
"url",
|
||||||
"url-manager",
|
"url-manager",
|
||||||
|
@ -180,13 +180,13 @@ export default class URLManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* set the url domain name
|
* set the url domain name
|
||||||
* @param val the domain name
|
* @param val the domain name (if set to null it will remove the domain)
|
||||||
*/
|
*/
|
||||||
public domain(val: string | null): this
|
public domain(val: string | null): this
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manipulate the url domain
|
* Manipulate the url domain
|
||||||
* @param { string | undefined } val the url domain (Optionnal)
|
* @param { string | null | undefined } val the url domain (Optionnal)
|
||||||
* @return { string | this }
|
* @return { string | this }
|
||||||
*/
|
*/
|
||||||
public domain(val?: string | null) {
|
public domain(val?: string | null) {
|
||||||
@ -195,9 +195,9 @@ export default class URLManager {
|
|||||||
}
|
}
|
||||||
if (val === null) {
|
if (val === null) {
|
||||||
delete this._domain
|
delete this._domain
|
||||||
} else {
|
return this
|
||||||
this._domain = val
|
|
||||||
}
|
}
|
||||||
|
this._domain = val
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user