@riotjs/util
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -12,3 +12,3 @@ export const EACH = 0 | ||
TAG, | ||
SLOT | ||
} | ||
SLOT, | ||
} |
// Riot.js constants that can be used across more modules | ||
export const | ||
COMPONENTS_IMPLEMENTATION_MAP = new Map(), | ||
export const COMPONENTS_IMPLEMENTATION_MAP = new Map(), | ||
DOM_COMPONENT_INSTANCE_PROPERTY = Symbol('riot-component'), | ||
@@ -6,0 +5,0 @@ PLUGINS_SET = new Set(), |
17
dom.js
@@ -1,2 +0,2 @@ | ||
import {dashToCamelCase} from './strings.js' | ||
import { dashToCamelCase } from './strings.js' | ||
@@ -45,6 +45,5 @@ /** | ||
// eslint-disable-next-line fp/no-loops,fp/no-let | ||
for (let i = 0;i < children.length; i++) removeChild(children[i]) | ||
for (let i = 0; i < children.length; i++) removeChild(children[i]) | ||
} | ||
/** | ||
@@ -55,3 +54,3 @@ * Remove a node | ||
*/ | ||
export const removeChild = node => node.remove() | ||
export const removeChild = (node) => node.remove() | ||
@@ -64,3 +63,6 @@ /** | ||
*/ | ||
export const insertBefore = (newNode, refNode) => refNode && refNode.parentNode && refNode.parentNode.insertBefore(newNode, refNode) | ||
export const insertBefore = (newNode, refNode) => | ||
refNode && | ||
refNode.parentNode && | ||
refNode.parentNode.insertBefore(newNode, refNode) | ||
@@ -73,2 +75,5 @@ /** | ||
*/ | ||
export const replaceChild = (newNode, replaced) => replaced && replaced.parentNode && replaced.parentNode.replaceChild(newNode, replaced) | ||
export const replaceChild = (newNode, replaced) => | ||
replaced && | ||
replaced.parentNode && | ||
replaced.parentNode.replaceChild(newNode, replaced) |
@@ -10,3 +10,3 @@ export const ATTRIBUTE = 0 | ||
TEXT, | ||
VALUE | ||
} | ||
VALUE, | ||
} |
@@ -1,2 +0,2 @@ | ||
import {isFunction} from './checks.js' | ||
import { isFunction } from './checks.js' | ||
@@ -15,3 +15,3 @@ // does simply nothing | ||
export function autobindMethods(source, methods) { | ||
methods.forEach(method => { | ||
methods.forEach((method) => { | ||
source[method] = source[method].bind(source) | ||
@@ -29,5 +29,7 @@ }) | ||
export function callOrAssign(source) { | ||
return isFunction(source) ? (source.prototype && source.prototype.constructor ? | ||
new source() : source() | ||
) : source | ||
return isFunction(source) | ||
? source.prototype && source.prototype.constructor | ||
? new source() | ||
: source() | ||
: source | ||
} |
38
misc.js
@@ -1,3 +0,3 @@ | ||
import {ATTRIBUTE, VALUE} from './expression-types.js' | ||
import {dashToCamelCase} from './strings.js' | ||
import { ATTRIBUTE, VALUE } from './expression-types.js' | ||
import { dashToCamelCase } from './strings.js' | ||
@@ -21,4 +21,6 @@ /** | ||
const cache = new Map() | ||
const cached = val => { | ||
return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val) | ||
const cached = (val) => { | ||
return cache.has(val) | ||
? cache.get(val) | ||
: cache.set(val, fn.call(this, val)) && cache.get(val) | ||
} | ||
@@ -36,18 +38,18 @@ cached.cache = cache | ||
return attributes.reduce((acc, attribute) => { | ||
const {value, type} = attribute | ||
const { value, type } = attribute | ||
switch (true) { | ||
// spread attribute | ||
case !attribute.name && type === ATTRIBUTE: | ||
return { | ||
...acc, | ||
...value | ||
} | ||
// value attribute | ||
case type === VALUE: | ||
acc.value = attribute.value | ||
break | ||
// normal attributes | ||
default: | ||
acc[dashToCamelCase(attribute.name)] = attribute.value | ||
// spread attribute | ||
case !attribute.name && type === ATTRIBUTE: | ||
return { | ||
...acc, | ||
...value, | ||
} | ||
// value attribute | ||
case type === VALUE: | ||
acc.value = attribute.value | ||
break | ||
// normal attributes | ||
default: | ||
acc[dashToCamelCase(attribute.name)] = attribute.value | ||
} | ||
@@ -54,0 +56,0 @@ |
@@ -1,2 +0,1 @@ | ||
/** | ||
@@ -17,3 +16,3 @@ * Helper function to set an immutable property | ||
configurable: true, | ||
...options | ||
...options, | ||
}) | ||
@@ -20,0 +19,0 @@ /* eslint-enable fp/no-mutating-methods */ |
{ | ||
"name": "@riotjs/util", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Riot.js util functions", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"prepublishOnly": "npm test", | ||
"lint": "eslint *.js", | ||
"lint": "npx prettier -c . && eslint *.js", | ||
"test": "npm run lint && mocha -r jsdom-global/register *.spec.js" | ||
@@ -41,9 +41,11 @@ }, | ||
"devDependencies": { | ||
"chai": "^4.3.6", | ||
"eslint": "^8.26.0", | ||
"eslint-config-riot": "^3.0.0", | ||
"jsdom": "20.0.1", | ||
"@riotjs/prettier-config": "^1.0.1", | ||
"chai": "^4.3.7", | ||
"eslint": "^8.37.0", | ||
"eslint-config-riot": "^4.0.0", | ||
"jsdom": "21.1.1", | ||
"jsdom-global": "3.0.2", | ||
"mocha": "^10.1.0" | ||
"mocha": "^10.2.0", | ||
"prettier": "^2.8.7" | ||
} | ||
} |
@@ -11,10 +11,10 @@ # @riotjs/util | ||
[ci-image]:https://img.shields.io/github/workflow/status/riot/util/test?style=flat-square | ||
[ci-url]:https://github.com/riot/util/actions | ||
[ci-image]: https://img.shields.io/github/actions/workflow/status/riot/util/test.yml?style=flat-square | ||
[ci-url]: https://github.com/riot/util/actions | ||
[license-image]: https://img.shields.io/badge/license-MIT-000000.svg?style=flat-square | ||
[license-url]: LICENSE | ||
[npm-version-image]: https://img.shields.io/npm/v/@riotjs/util.svg?style=flat-square | ||
[license-url]: LICENSE | ||
[npm-version-image]: https://img.shields.io/npm/v/@riotjs/util.svg?style=flat-square | ||
[npm-downloads-image]: https://img.shields.io/npm/dm/@riotjs/util.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/@riotjs/util | ||
[npm-url]: https://npmjs.org/package/@riotjs/util | ||
[codeclimate-image]: https://api.codeclimate.com/v1/badges/352cc9afc317e20f7f0a/maintainability | ||
[codeclimate-url]: https://codeclimate.com/github/riot/util | ||
[codeclimate-url]: https://codeclimate.com/github/riot/util |
@@ -17,2 +17,2 @@ /** | ||
return string.replace(/-(\w)/g, (_, c) => c.toUpperCase()) | ||
} | ||
} |
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
13639
339
8