@podium/utils
Advanced tools
Comparing version 5.0.0-next.3 to 5.0.0-next.4
181
CHANGELOG.md
@@ -0,1 +1,49 @@ | ||
# [5.0.0-next.4](https://github.com/podium-lib/utils/compare/v5.0.0-next.3...v5.0.0-next.4) (2021-04-27) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.0.4 ([5ff49c0](https://github.com/podium-lib/utils/commit/5ff49c02e0999b2e7c105caad93f626d518d686f)) | ||
* **deps:** update dependency @podium/schemas to v4.0.5 ([9bf1a14](https://github.com/podium-lib/utils/commit/9bf1a1491a59d17b4715e06fd3692ba8f1907ffa)) | ||
* **deps:** update dependency @podium/schemas to v4.1.0 ([4ff5fe9](https://github.com/podium-lib/utils/commit/4ff5fe9ea31c7e999d953ca5acb5bd6417dbf3c5)) | ||
* **deps:** update dependency @podium/schemas to v4.1.1 ([f2cc938](https://github.com/podium-lib/utils/commit/f2cc93840039fc47cac7e9ef2cd95dbb1395c8e5)) | ||
* **deps:** update dependency @podium/schemas to v4.1.10 ([5a10235](https://github.com/podium-lib/utils/commit/5a10235b74a5faa7fc9cf65efc7aab69883f6781)) | ||
* **deps:** update dependency @podium/schemas to v4.1.11 ([20941c6](https://github.com/podium-lib/utils/commit/20941c6912b60a4dd3c654a3e674589a0713ae30)) | ||
* **deps:** update dependency @podium/schemas to v4.1.13 ([f677772](https://github.com/podium-lib/utils/commit/f6777726c06362b1de6acf1e613db1b0928456ba)) | ||
* **deps:** update dependency @podium/schemas to v4.1.14 ([0deb0d0](https://github.com/podium-lib/utils/commit/0deb0d0ffa14735d6a1e850291322bb670eb5436)) | ||
* **deps:** update dependency @podium/schemas to v4.1.15 ([446458c](https://github.com/podium-lib/utils/commit/446458c6bd75e2ca8efd21d37107188a7146cd1e)) | ||
* Update @podium/schema to version 4.1.9 to fix ajv error ([#110](https://github.com/podium-lib/utils/issues/110)) ([08ee7df](https://github.com/podium-lib/utils/commit/08ee7dfa6bc8b413bb8ee12dd778606f0c6c04e4)) | ||
* **deps:** update dependency @podium/schemas to v4.0.7 ([cbded99](https://github.com/podium-lib/utils/commit/cbded9938631209d7d1c3da3bf7600379d0524dc)) | ||
* **deps:** update dependency @podium/schemas to v4.1.2 ([04c7b1b](https://github.com/podium-lib/utils/commit/04c7b1be013fb6be5b6a1d5a18f2a12946f0273f)) | ||
* **deps:** update dependency @podium/schemas to v4.1.3 ([e663829](https://github.com/podium-lib/utils/commit/e66382960675a7770a77913611b67042efdf4755)) | ||
* **deps:** update dependency @podium/schemas to v4.1.4 ([4cb9bb6](https://github.com/podium-lib/utils/commit/4cb9bb65c6da0cc56bbb96b9f9555ce3067a1359)) | ||
* **deps:** update dependency @podium/schemas to v4.1.5 ([d920dab](https://github.com/podium-lib/utils/commit/d920dabf5f3ad3f5d55f3da204f01f36b83a1e17)) | ||
* **deps:** update dependency @podium/schemas to v4.1.6 ([f92062c](https://github.com/podium-lib/utils/commit/f92062c4d3d403aef90978efce41e554645b97b2)) | ||
* **deps:** update dependency @podium/schemas to v4.1.7 ([9eac72d](https://github.com/podium-lib/utils/commit/9eac72dc56b584ddfe9343757429f1b7daea86f3)) | ||
* **deps:** update dependency @podium/schemas to v4.1.8 ([c8fde78](https://github.com/podium-lib/utils/commit/c8fde78758d7a6e36e90d37d066f11806ffad885)) | ||
* **deps:** update dependency camelcase to v6.1.0 ([ef22149](https://github.com/podium-lib/utils/commit/ef2214918172d1b6044b72f44771c7fb22f5aa77)) | ||
* **deps:** update dependency camelcase to v6.2.0 ([3e9dec9](https://github.com/podium-lib/utils/commit/3e9dec90c4d511b5d6abe1360bf9a1a8195d2833)) | ||
### Features | ||
* add .buildReactLinkAttributes and .buildReactScriptAttributes methods ([ffb0bff](https://github.com/podium-lib/utils/commit/ffb0bff96a998694cb7102e0f9dc14c943914f7a)) | ||
* add .toReactAttrs() method to AssetJs and AssetCss classes and integration tests ([7ab097f](https://github.com/podium-lib/utils/commit/7ab097f51d48001c884eb734eb823b0516e2eb24)) | ||
* Convert to ESM ([#119](https://github.com/podium-lib/utils/issues/119)) ([349c5b9](https://github.com/podium-lib/utils/commit/349c5b928726d8f808107ce4d0c0abfd1d15e937)) | ||
### BREAKING CHANGES | ||
* Convert from CommonJS to ESM | ||
* feat: convert to ESM | ||
* fix: Remove outcommented code | ||
* ci: Add build step for backward compat to CJS | ||
* ci: Ignore linting dist directory | ||
Co-authored-by: Trygve Lie <trygve.lie@finn.no> | ||
# [5.0.0-next.3](https://github.com/podium-lib/utils/compare/v5.0.0-next.2...v5.0.0-next.3) (2020-07-27) | ||
@@ -56,2 +104,3 @@ | ||
# [5.0.0-next.2](https://github.com/podium-lib/utils/compare/v5.0.0-next.1...v5.0.0-next.2) (2020-07-15) | ||
## [4.4.16](https://github.com/podium-lib/utils/compare/v4.4.15...v4.4.16) (2021-04-11) | ||
@@ -61,7 +110,116 @@ | ||
* **deps:** update dependency @podium/schemas to v4.1.15 ([446458c](https://github.com/podium-lib/utils/commit/446458c6bd75e2ca8efd21d37107188a7146cd1e)) | ||
## [4.4.15](https://github.com/podium-lib/utils/compare/v4.4.14...v4.4.15) (2021-04-02) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.1.14 ([0deb0d0](https://github.com/podium-lib/utils/commit/0deb0d0ffa14735d6a1e850291322bb670eb5436)) | ||
## [4.4.14](https://github.com/podium-lib/utils/compare/v4.4.13...v4.4.14) (2021-04-02) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.1.13 ([f677772](https://github.com/podium-lib/utils/commit/f6777726c06362b1de6acf1e613db1b0928456ba)) | ||
## [4.4.13](https://github.com/podium-lib/utils/compare/v4.4.12...v4.4.13) (2021-04-01) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.1.10 ([5a10235](https://github.com/podium-lib/utils/commit/5a10235b74a5faa7fc9cf65efc7aab69883f6781)) | ||
* **deps:** update dependency @podium/schemas to v4.1.11 ([20941c6](https://github.com/podium-lib/utils/commit/20941c6912b60a4dd3c654a3e674589a0713ae30)) | ||
## [4.4.12](https://github.com/podium-lib/utils/compare/v4.4.11...v4.4.12) (2021-03-30) | ||
### Bug Fixes | ||
* Update @podium/schema to version 4.1.9 to fix ajv error ([#110](https://github.com/podium-lib/utils/issues/110)) ([08ee7df](https://github.com/podium-lib/utils/commit/08ee7dfa6bc8b413bb8ee12dd778606f0c6c04e4)) | ||
## [4.4.11](https://github.com/podium-lib/utils/compare/v4.4.10...v4.4.11) (2021-03-27) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.1.8 ([c8fde78](https://github.com/podium-lib/utils/commit/c8fde78758d7a6e36e90d37d066f11806ffad885)) | ||
## [4.4.10](https://github.com/podium-lib/utils/compare/v4.4.9...v4.4.10) (2021-03-26) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.1.7 ([9eac72d](https://github.com/podium-lib/utils/commit/9eac72dc56b584ddfe9343757429f1b7daea86f3)) | ||
## [4.4.9](https://github.com/podium-lib/utils/compare/v4.4.8...v4.4.9) (2021-03-20) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.1.6 ([f92062c](https://github.com/podium-lib/utils/commit/f92062c4d3d403aef90978efce41e554645b97b2)) | ||
## [4.4.8](https://github.com/podium-lib/utils/compare/v4.4.7...v4.4.8) (2021-03-08) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.1.5 ([d920dab](https://github.com/podium-lib/utils/commit/d920dabf5f3ad3f5d55f3da204f01f36b83a1e17)) | ||
## [4.4.7](https://github.com/podium-lib/utils/compare/v4.4.6...v4.4.7) (2021-03-07) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.1.4 ([4cb9bb6](https://github.com/podium-lib/utils/commit/4cb9bb65c6da0cc56bbb96b9f9555ce3067a1359)) | ||
## [4.4.6](https://github.com/podium-lib/utils/compare/v4.4.5...v4.4.6) (2021-02-17) | ||
### Bug Fixes | ||
* Simplify js and css value validation ([#70](https://github.com/podium-lib/utils/issues/70)) ([05a1ffc](https://github.com/podium-lib/utils/commit/05a1ffc17bce3249b349b218a9b5ea8585db5df8)) | ||
# [5.0.0-next.1](https://github.com/podium-lib/utils/compare/v4.3.0...v5.0.0-next.1) (2020-07-12) | ||
* **deps:** update dependency @podium/schemas to v4.1.3 ([e663829](https://github.com/podium-lib/utils/commit/e66382960675a7770a77913611b67042efdf4755)) | ||
## [4.4.5](https://github.com/podium-lib/utils/compare/v4.4.4...v4.4.5) (2021-02-11) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.1.2 ([04c7b1b](https://github.com/podium-lib/utils/commit/04c7b1be013fb6be5b6a1d5a18f2a12946f0273f)) | ||
## [4.4.4](https://github.com/podium-lib/utils/compare/v4.4.3...v4.4.4) (2021-02-02) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.1.1 ([f2cc938](https://github.com/podium-lib/utils/commit/f2cc93840039fc47cac7e9ef2cd95dbb1395c8e5)) | ||
## [4.4.3](https://github.com/podium-lib/utils/compare/v4.4.2...v4.4.3) (2021-01-22) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.1.0 ([4ff5fe9](https://github.com/podium-lib/utils/commit/4ff5fe9ea31c7e999d953ca5acb5bd6417dbf3c5)) | ||
## [4.4.2](https://github.com/podium-lib/utils/compare/v4.4.1...v4.4.2) (2021-01-21) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.0.7 ([cbded99](https://github.com/podium-lib/utils/commit/cbded9938631209d7d1c3da3bf7600379d0524dc)) | ||
## [4.4.1](https://github.com/podium-lib/utils/compare/v4.4.0...v4.4.1) (2020-10-28) | ||
### Bug Fixes | ||
* **deps:** update dependency camelcase to v6.2.0 ([3e9dec9](https://github.com/podium-lib/utils/commit/3e9dec90c4d511b5d6abe1360bf9a1a8195d2833)) | ||
# [4.4.0](https://github.com/podium-lib/utils/compare/v4.3.3...v4.4.0) (2020-10-12) | ||
### Features | ||
@@ -77,3 +235,26 @@ | ||
Co-authored-by: Trygve Lie <trygve.lie@finn.no> | ||
* add .buildReactLinkAttributes and .buildReactScriptAttributes methods ([ffb0bff](https://github.com/podium-lib/utils/commit/ffb0bff96a998694cb7102e0f9dc14c943914f7a)) | ||
* add .toReactAttrs() method to AssetJs and AssetCss classes and integration tests ([7ab097f](https://github.com/podium-lib/utils/commit/7ab097f51d48001c884eb734eb823b0516e2eb24)) | ||
## [4.3.3](https://github.com/podium-lib/utils/compare/v4.3.2...v4.3.3) (2020-10-10) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.0.5 ([9bf1a14](https://github.com/podium-lib/utils/commit/9bf1a1491a59d17b4715e06fd3692ba8f1907ffa)) | ||
## [4.3.2](https://github.com/podium-lib/utils/compare/v4.3.1...v4.3.2) (2020-10-10) | ||
### Bug Fixes | ||
* **deps:** update dependency camelcase to v6.1.0 ([ef22149](https://github.com/podium-lib/utils/commit/ef2214918172d1b6044b72f44771c7fb22f5aa77)) | ||
## [4.3.1](https://github.com/podium-lib/utils/compare/v4.3.0...v4.3.1) (2020-09-13) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/schemas to v4.0.4 ([5ff49c0](https://github.com/podium-lib/utils/commit/5ff49c02e0999b2e7c105caad93f626d518d686f)) | ||
# [4.3.0](https://github.com/podium-lib/utils/compare/v4.2.5...v4.3.0) (2020-06-26) | ||
@@ -80,0 +261,0 @@ |
@@ -1,6 +0,4 @@ | ||
'use strict'; | ||
import { uriIsRelative, pathnameBuilder } from './utils.js'; | ||
import { buildLinkElement, buildReactLinkAttributes } from './html-utils.js'; | ||
const { uriIsRelative, pathnameBuilder } = require('./utils'); | ||
const { buildLinkElement } = require('./html-utils'); | ||
const inspect = Symbol.for('nodejs.util.inspect.custom'); | ||
@@ -17,3 +15,3 @@ | ||
const PodiumAssetCss = class PodiumAssetCss { | ||
export default class PodiumAssetCss { | ||
#crossorigin; | ||
@@ -175,2 +173,6 @@ #pathname; | ||
} | ||
toJsxAttributes() { | ||
return buildReactLinkAttributes(this); | ||
} | ||
@@ -181,3 +183,1 @@ get [Symbol.toStringTag]() { | ||
}; | ||
module.exports = PodiumAssetCss; |
@@ -1,6 +0,6 @@ | ||
'use strict'; | ||
const { uriIsRelative, pathnameBuilder } = require('./utils'); | ||
const { buildScriptElement } = require('./html-utils'); | ||
import { uriIsRelative, pathnameBuilder } from './utils.js'; | ||
import { buildScriptElement, buildReactScriptAttributes } from './html-utils.js'; | ||
const inspect = Symbol.for('nodejs.util.inspect.custom'); | ||
@@ -18,3 +18,3 @@ | ||
const PodiumAssetJs = class PodiumAssetJs { | ||
export default class PodiumAssetJs { | ||
#referrerpolicy; | ||
@@ -177,2 +177,6 @@ #crossorigin; | ||
toJsxAttributes() { | ||
return buildReactScriptAttributes(this); | ||
} | ||
get [Symbol.toStringTag]() { | ||
@@ -182,3 +186,1 @@ return 'PodiumAssetJs'; | ||
}; | ||
module.exports = PodiumAssetJs; |
@@ -1,6 +0,4 @@ | ||
'use strict'; | ||
import * as utils from './html-utils.js'; | ||
const utils = require('./html-utils'); | ||
const document = (incoming = {}, body = '', head = '') => { | ||
export const document = (incoming = {}, body = '', head = '') => { | ||
let scripts = incoming.js; | ||
@@ -29,3 +27,1 @@ let styles = incoming.css; | ||
}; | ||
module.exports = document; |
@@ -1,4 +0,4 @@ | ||
'use strict'; | ||
/* eslint-disable no-restricted-syntax */ | ||
const notEmpty = (value) => { | ||
export const notEmpty = (value) => { | ||
if (value === false) return value; | ||
@@ -11,33 +11,33 @@ if (value === undefined) return false; | ||
const buildScriptElement = (obj) => { | ||
export const buildScriptAttributes = (obj) => { | ||
const args = []; | ||
args.push(`src="${obj.value}"`); | ||
args.push({ key: 'src', value: obj.value }); | ||
if (obj.type === 'esm' || obj.type === 'module') { | ||
args.push('type="module"'); | ||
args.push({ key: 'type', value: 'module' }); | ||
} | ||
if (notEmpty(obj.referrerpolicy)) { | ||
args.push(`referrerpolicy="${obj.referrerpolicy}"`); | ||
args.push({ key: 'referrerpolicy', value: obj.referrerpolicy }); | ||
} | ||
if (obj.crossorigin || obj.crossorigin === '') { | ||
if (obj.crossorigin === true) args.push(`crossorigin`); | ||
else args.push(`crossorigin="${obj.crossorigin}"`); | ||
if (obj.crossorigin === true) args.push({ key: 'crossorigin' }); | ||
else args.push({ key: 'crossorigin', value: obj.crossorigin }); | ||
} | ||
if (notEmpty(obj.integrity)) { | ||
args.push(`integrity="${obj.integrity}"`); | ||
args.push({ key: 'integrity', value: obj.integrity }); | ||
} | ||
if (notEmpty(obj.nomodule)) { | ||
args.push('nomodule'); | ||
args.push({ key: 'nomodule' }); | ||
} | ||
if (notEmpty(obj.async)) { | ||
args.push('async'); | ||
args.push({ key: 'async' }); | ||
} | ||
if (notEmpty(obj.defer)) { | ||
args.push('defer'); | ||
args.push({ key: 'defer' }); | ||
} | ||
@@ -47,50 +47,86 @@ | ||
obj.data.forEach((item) => { | ||
args.push(`data-${item.key}="${item.value}"`); | ||
args.push({ key: `data-${item.key}`, value: item.value }); | ||
}); | ||
} | ||
return `<script ${args.join(' ')}></script>`; | ||
return args; | ||
}; | ||
const buildLinkElement = (obj) => { | ||
export const buildReactScriptAttributes = (obj) => { | ||
const attrs = {}; | ||
for (const { key, value } of buildScriptAttributes(obj)) { | ||
if (key === 'crossorigin') attrs.crossOrigin = value || ''; | ||
else if (key === 'referrerpolicy') attrs.referrerPolicy = value; | ||
else if (key === 'nomodule') attrs.noModule = value || true; | ||
else if (key && !value) attrs[key] = true; | ||
else attrs[key] = value; | ||
} | ||
return attrs; | ||
} | ||
export const buildScriptElement = (obj) => { | ||
const attrs = buildScriptAttributes(obj).map(({key, value}) => { | ||
if (!value && value !== '') return key; | ||
return `${key}="${value}"`; | ||
}) | ||
return `<script ${attrs.join(' ')}></script>`; | ||
}; | ||
export const buildLinkAttributes = (obj) => { | ||
const args = []; | ||
args.push(`href="${obj.value}"`); | ||
args.push({ key: 'href', value: obj.value }); | ||
if (obj.crossorigin || obj.crossorigin === '') { | ||
if (obj.crossorigin === true) args.push(`crossorigin`); | ||
else args.push(`crossorigin="${obj.crossorigin}"`); | ||
if (obj.crossorigin === true) args.push({ key: 'crossorigin' }); | ||
else args.push({ key: 'crossorigin', value: obj.crossorigin }); | ||
} | ||
if (notEmpty(obj.disabled)) { | ||
args.push('disabled'); | ||
args.push({ key: 'disabled' }); | ||
} | ||
if (notEmpty(obj.hreflang)) { | ||
args.push(`hreflang="${obj.hreflang}"`); | ||
args.push({ key: 'hreflang', value: obj.hreflang }); | ||
} | ||
if (notEmpty(obj.title)) { | ||
args.push(`title="${obj.title}"`); | ||
args.push({ key: 'title', value: obj.title }); | ||
} | ||
if (notEmpty(obj.media)) { | ||
args.push(`media="${obj.media}"`); | ||
args.push({ key: 'media', value: obj.media }); | ||
} | ||
if (notEmpty(obj.as)) { | ||
args.push(`as="${obj.as}"`); | ||
args.push({ key: 'as', value: obj.as }); | ||
} | ||
if (notEmpty(obj.type)) { | ||
args.push(`type="${obj.type}"`); | ||
args.push({ key: 'type', value: obj.type }); | ||
} | ||
if (notEmpty(obj.rel)) { | ||
args.push(`rel="${obj.rel}"`); | ||
args.push({ key: 'rel', value: obj.rel }); | ||
} | ||
return `<link ${args.join(' ')}>`; | ||
return args; | ||
}; | ||
module.exports.buildScriptElement = buildScriptElement; | ||
module.exports.buildLinkElement = buildLinkElement; | ||
export const buildReactLinkAttributes = (obj) => { | ||
const attrs = {}; | ||
for (const { key, value } of buildLinkAttributes(obj)) { | ||
if (key === 'crossorigin') attrs.crossOrigin = value || ''; | ||
else if (key === 'hreflang') attrs.hrefLang = value; | ||
else if (key && !value) attrs[key] = true; | ||
else attrs[key] = value; | ||
} | ||
return attrs; | ||
} | ||
export const buildLinkElement = (obj) => { | ||
const attrs = buildLinkAttributes(obj).map(({key, value}) => { | ||
if (!value && value !== '') return key; | ||
return `${key}="${value}"`; | ||
}) | ||
return `<link ${attrs.join(' ')}>`; | ||
}; |
@@ -1,6 +0,4 @@ | ||
'use strict'; | ||
import originalUrl from 'original-url'; | ||
import { URL } from 'url'; | ||
const originalUrl = require('original-url'); | ||
const { URL } = require('url'); | ||
const inspect = Symbol.for('nodejs.util.inspect.custom'); | ||
@@ -17,3 +15,3 @@ | ||
const PodiumHttpIncoming = class PodiumHttpIncoming { | ||
export default class PodiumHttpIncoming { | ||
#development; | ||
@@ -196,3 +194,1 @@ #response; | ||
}; | ||
module.exports = PodiumHttpIncoming; |
@@ -1,26 +0,24 @@ | ||
'use strict'; | ||
import * as Incoming from "./http-incoming.js"; | ||
import { document } from "./html-document.js"; | ||
import * as Css from "./asset-css.js"; | ||
import * as Js from "./asset-js.js"; | ||
import * as utils from "./utils.js" | ||
import * as html from "./html-utils.js" | ||
const HttpIncoming = require('./http-incoming'); | ||
const document = require('./html-document'); | ||
const AssetCss = require('./asset-css'); | ||
const AssetJs = require('./asset-js'); | ||
const utils = require('./utils'); | ||
const html = require('./html-utils'); | ||
module.exports.isString = utils.isString; | ||
module.exports.isFunction = utils.isFunction; | ||
module.exports.uriBuilder = utils.uriBuilder; | ||
module.exports.uriIsRelative = utils.uriIsRelative; | ||
module.exports.pathnameBuilder = utils.pathnameBuilder; | ||
module.exports.uriRelativeToAbsolute = utils.uriRelativeToAbsolute; | ||
module.exports.setAtLocalsPodium = utils.setAtLocalsPodium; | ||
module.exports.getFromLocalsPodium = utils.getFromLocalsPodium; | ||
module.exports.duplicateOnLocalsPodium = utils.duplicateOnLocalsPodium; | ||
module.exports.serializeContext = utils.serializeContext; | ||
module.exports.deserializeContext = utils.deserializeContext; | ||
module.exports.buildScriptElement = html.buildScriptElement; | ||
module.exports.buildLinkElement = html.buildLinkElement; | ||
module.exports.HttpIncoming = HttpIncoming; | ||
module.exports.template = document; | ||
module.exports.AssetCss = AssetCss; | ||
module.exports.AssetJs = AssetJs; | ||
export const {isString} = utils; | ||
export const {isFunction} = utils; | ||
export const {uriBuilder} = utils; | ||
export const {uriIsRelative} = utils; | ||
export const {pathnameBuilder} = utils; | ||
export const {uriRelativeToAbsolute} = utils; | ||
export const {setAtLocalsPodium} = utils; | ||
export const {getFromLocalsPodium} = utils; | ||
export const {duplicateOnLocalsPodium} = utils; | ||
export const {serializeContext} = utils; | ||
export const {deserializeContext} = utils; | ||
export const {buildScriptElement} = html; | ||
export const {buildLinkElement} = html; | ||
export const HttpIncoming = Incoming; | ||
export const template = document; | ||
export const AssetCss = Css; | ||
export const AssetJs = Js; |
@@ -1,6 +0,4 @@ | ||
'use strict'; | ||
import camelcase from 'camelcase'; | ||
import { URL } from 'url'; | ||
const camelcase = require('camelcase'); | ||
const { URL } = require('url'); | ||
/** | ||
@@ -13,3 +11,3 @@ * Checks if a value is a string | ||
*/ | ||
const isString = str => typeof str === 'string'; | ||
export const isString = str => typeof str === 'string'; | ||
@@ -23,3 +21,3 @@ /** | ||
*/ | ||
const isFunction = fn => { | ||
export const isFunction = fn => { | ||
const type = {}.toString.call(fn); | ||
@@ -40,3 +38,3 @@ return type === '[object Function]' || type === '[object AsyncFunction]'; | ||
const pathnameBuilder = (...args) => { | ||
export const pathnameBuilder = (...args) => { | ||
const separator = '/'; | ||
@@ -87,3 +85,3 @@ let prefixCheck = true; | ||
const uriBuilder = (input = '', base = '', extra = '') => { | ||
export const uriBuilder = (input = '', base = '', extra = '') => { | ||
const uriObj = new URL(base); | ||
@@ -105,3 +103,3 @@ const basePath = uriObj.pathname | ||
const uriIsRelative = uri => uri.substr(0, 4) !== 'http'; | ||
export const uriIsRelative = uri => uri.substr(0, 4) !== 'http'; | ||
@@ -119,5 +117,5 @@ /** | ||
const uriRelativeToAbsolute = (input = '', base = '', extra = '') => { | ||
if (this.uriIsRelative(input)) { | ||
return this.uriBuilder(input, base, extra); | ||
export const uriRelativeToAbsolute = (input = '', base = '', extra = '') => { | ||
if (uriIsRelative(input)) { | ||
return uriBuilder(input, base, extra); | ||
} | ||
@@ -141,3 +139,3 @@ return input; | ||
const setAtLocalsPodium = (response = {}, property, value) => { | ||
export const setAtLocalsPodium = (response = {}, property, value) => { | ||
if (!response.locals) { | ||
@@ -168,3 +166,3 @@ response.locals = {}; | ||
const getFromLocalsPodium = (response = {}, property) => { | ||
export const getFromLocalsPodium = (response = {}, property) => { | ||
if (!response.locals) { | ||
@@ -196,3 +194,3 @@ return null; | ||
const duplicateOnLocalsPodium = (response = {}, fromProperty, toProperty) => | ||
export const duplicateOnLocalsPodium = (response = {}, fromProperty, toProperty) => | ||
setAtLocalsPodium( | ||
@@ -214,3 +212,3 @@ response, | ||
const serializeContext = (headers = {}, context = {}, arg = '') => { | ||
export const serializeContext = (headers = {}, context = {}, arg = '') => { | ||
const localHeaders = headers; | ||
@@ -238,3 +236,3 @@ Object.keys(context).forEach(key => { | ||
const deserializeContext = (headers = {}, prefix = 'podium') => { | ||
export const deserializeContext = (headers = {}, prefix = 'podium') => { | ||
const context = {}; | ||
@@ -249,13 +247,1 @@ Object.keys(headers).forEach(key => { | ||
}; | ||
module.exports.isString = isString; | ||
module.exports.isFunction = isFunction; | ||
module.exports.uriBuilder = uriBuilder; | ||
module.exports.uriIsRelative = uriIsRelative; | ||
module.exports.pathnameBuilder = pathnameBuilder; | ||
module.exports.uriRelativeToAbsolute = uriRelativeToAbsolute; | ||
module.exports.setAtLocalsPodium = setAtLocalsPodium; | ||
module.exports.getFromLocalsPodium = getFromLocalsPodium; | ||
module.exports.duplicateOnLocalsPodium = duplicateOnLocalsPodium; | ||
module.exports.serializeContext = serializeContext; | ||
module.exports.deserializeContext = deserializeContext; |
{ | ||
"name": "@podium/utils", | ||
"version": "5.0.0-next.3", | ||
"version": "5.0.0-next.4", | ||
"description": "Common generic utility methods shared by @podium modules.", | ||
"type": "module", | ||
"license": "MIT", | ||
@@ -26,5 +27,10 @@ "keywords": [ | ||
"LICENSE", | ||
"dist", | ||
"lib" | ||
], | ||
"main": "./lib/main.js", | ||
"main": "./dist/main.js", | ||
"exports": { | ||
"require": "./dist/validate.js", | ||
"import": "./lib/main.js" | ||
}, | ||
"types": "index.d.ts", | ||
@@ -34,5 +40,7 @@ "scripts": { | ||
"lint:fix": "eslint --fix .", | ||
"test": "tap --no-esm tests/*.js", | ||
"test:snapshots:update": "tap --no-esm tests/*.js --snapshot", | ||
"bench": "node benchmark/benchmark.js" | ||
"test": "tap --no-check-coverage", | ||
"test:snapshots:update": "tap --snapshot", | ||
"bench": "node benchmark/benchmark.js", | ||
"prepare": "npm run -s build", | ||
"build": "rollup -c" | ||
}, | ||
@@ -43,21 +51,22 @@ "devDependencies": { | ||
"@semantic-release/git": "9.0.0", | ||
"@semantic-release/github": "7.0.7", | ||
"@semantic-release/npm": "7.0.5", | ||
"@semantic-release/release-notes-generator": "9.0.1", | ||
"semantic-release": "17.1.1", | ||
"@podium/schemas": "5.0.0-next.1", | ||
"@semantic-release/github": "7.2.1", | ||
"@semantic-release/npm": "7.1.1", | ||
"@semantic-release/release-notes-generator": "9.0.2", | ||
"semantic-release": "17.4.2", | ||
"benchmark": "2.1.4", | ||
"eslint": "7.5.0", | ||
"eslint-config-airbnb-base": "14.2.0", | ||
"eslint-config-prettier": "6.11.0", | ||
"eslint-plugin-import": "2.22.0", | ||
"eslint-plugin-prettier": "3.1.4", | ||
"eslint": "7.25.0", | ||
"eslint-config-airbnb-base": "14.2.1", | ||
"eslint-config-prettier": "8.3.0", | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint-plugin-prettier": "3.4.0", | ||
"rollup": "2.45.2", | ||
"babel-eslint": "10.1.0", | ||
"prettier": "2.0.2", | ||
"tap": "14.10.8" | ||
"tap": "15.0.5", | ||
"prettier": "2.2.1" | ||
}, | ||
"dependencies": { | ||
"original-url": "1.2.3", | ||
"camelcase": "6.0.0" | ||
"@podium/schemas": "5.0.0-next.4", | ||
"camelcase": "6.2.0", | ||
"original-url": "1.2.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75154
20
1734
Yes
3
+ Added@podium/schemas@5.0.0-next.4
+ Added@podium/schemas@5.0.0-next.4(transitive)
+ Addedajv@8.1.0(transitive)
+ Addedajv-formats@2.0.2(transitive)
+ Addedcamelcase@6.2.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedjson-schema-traverse@1.0.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedrequire-from-string@2.0.2(transitive)
+ Addeduri-js@4.4.1(transitive)
- Removedcamelcase@6.0.0(transitive)
Updatedcamelcase@6.2.0