Lint and format src/runtime/internal/utils.js

pull/8569/head
S. Elliott Johnson 3 years ago
parent faf3e5403f
commit 7da65e0904

@ -8,8 +8,7 @@ export const identity = (x) => x;
*/
export function assign(tar, src) {
// @ts-ignore
for (const k in src)
tar[k] = src[k];
for (const k in src) tar[k] = src[k];
return tar;
}
// Adapted from https://github.com/then/is-promise/blob/master/index.js
@ -18,9 +17,11 @@ export function assign(tar, src) {
* @returns {boolean}
*/
export function is_promise(value) {
return (!!value &&
return (
!!value &&
(typeof value === 'object' || typeof value === 'function') &&
typeof value.then === 'function');
typeof value.then === 'function'
);
}
/** @returns {void} */
export function add_location(element, file, line, column, char) {
@ -129,14 +130,29 @@ export function get_slot_changes(definition, $$scope, dirty, fn) {
return $$scope.dirty;
}
/** @returns {void} */
export function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {
export function update_slot_base(
slot,
slot_definition,
ctx,
$$scope,
slot_changes,
get_slot_context_fn
) {
if (slot_changes) {
const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
slot.p(slot_context, slot_changes);
}
}
/** @returns {void} */
export function update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {
export function update_slot(
slot,
slot_definition,
ctx,
$$scope,
dirty,
get_slot_changes_fn,
get_slot_context_fn
) {
const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);
update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);
}
@ -155,18 +171,14 @@ export function get_all_dirty_from_scope($$scope) {
/** @returns {{}} */
export function exclude_internal_props(props) {
const result = {};
for (const k in props)
if (k[0] !== '$')
result[k] = props[k];
for (const k in props) if (k[0] !== '$') result[k] = props[k];
return result;
}
/** @returns {{}} */
export function compute_rest_props(props, keys) {
const rest = {};
keys = new Set(keys);
for (const k in props)
if (!keys.has(k) && k[0] !== '$')
rest[k] = props[k];
for (const k in props) if (!keys.has(k) && k[0] !== '$') rest[k] = props[k];
return rest;
}
/** @returns {{}} */
@ -181,8 +193,7 @@ export function compute_slots(slots) {
export function once(fn) {
let ran = false;
return function (...args) {
if (ran)
return;
if (ran) return;
ran = true;
fn.call(this, ...args);
};
@ -210,7 +221,3 @@ export function split_css_unit(value) {
return split ? [parseFloat(split[1]), split[2] || 'px'] : [value, 'px'];
}
export const contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];

Loading…
Cancel
Save