diff --git a/packages/linkify-react/src/linkify-react.mjs b/packages/linkify-react/src/linkify-react.mjs index b55d596..05fd050 100644 --- a/packages/linkify-react/src/linkify-react.mjs +++ b/packages/linkify-react/src/linkify-react.mjs @@ -1,5 +1,5 @@ import * as React from 'react'; -import { tokenize, Options, options } from 'linkifyjs'; +import { tokenize, Options } from 'linkifyjs'; /** * Given a string, converts to an array of valid React components @@ -10,7 +10,6 @@ import { tokenize, Options, options } from 'linkifyjs'; * @returns {React.ReactNodeArray} */ function stringToElements(str, opts, meta) { - const tokens = tokenize(str); const elements = []; @@ -28,7 +27,7 @@ function stringToElements(str, opts, meta) { if (!('key' in rendered.props)) { // Ensure generated element has unique key const key = `__linkify-el-${meta.elementId++}`; - const props = options.assign({ key }, rendered.props); + const props = Object.assign({ key }, rendered.props); rendered = React.cloneElement(rendered, props); } elements.push(rendered); @@ -60,9 +59,7 @@ function linkifyReactElement(element, opts, meta) { // ensure that we always generate unique element IDs for keys children.push.apply(children, stringToElements(child, opts, meta)); } else if (React.isValidElement(child)) { - if (typeof child.type === 'string' - && opts.ignoreTags.indexOf(child.type.toUpperCase()) >= 0 - ) { + if (typeof child.type === 'string' && opts.ignoreTags.indexOf(child.type.toUpperCase()) >= 0) { // Don't linkify this element children.push(child); } else { @@ -76,7 +73,7 @@ function linkifyReactElement(element, opts, meta) { // Set a default unique key, copy over remaining props const key = `__linkify-el-${meta.elementId++}`; - const newProps = options.assign({ key }, element.props); + const newProps = Object.assign({ key }, element.props); return React.cloneElement(element, newProps, children); } diff --git a/packages/linkifyjs/src/assign.mjs b/packages/linkifyjs/src/assign.mjs deleted file mode 100644 index 32813af..0000000 --- a/packages/linkifyjs/src/assign.mjs +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @template A - * @template B - * @param {A} target - * @param {B} properties - * @return {A & B} - */ -const assign = (target, properties) => { - for (const key in properties) { - target[key] = properties[key]; - } - return target; -}; - -export default assign; diff --git a/packages/linkifyjs/src/fsm.mjs b/packages/linkifyjs/src/fsm.mjs index 02f954f..398afb3 100644 --- a/packages/linkifyjs/src/fsm.mjs +++ b/packages/linkifyjs/src/fsm.mjs @@ -1,7 +1,6 @@ /** * Finite State Machine generation utilities */ -import assign from './assign.mjs'; /** * @template T @@ -273,7 +272,7 @@ State.prototype = { templateState = state.go(input); if (templateState) { nextState = new State(); - assign(nextState.j, templateState.j); + Object.assign(nextState.j, templateState.j); nextState.jr.push.apply(nextState.jr, templateState.jr); nextState.jd = templateState.jd; nextState.t = templateState.t; @@ -285,7 +284,7 @@ State.prototype = { // Ensure newly token is in the same groups as the old token if (groups) { if (nextState.t && typeof nextState.t === 'string') { - const allFlags = assign(flagsForToken(nextState.t, groups), flags); + const allFlags = Object.assign(flagsForToken(nextState.t, groups), flags); addToGroups(t, allFlags, groups); } else if (flags) { addToGroups(t, flags, groups); diff --git a/packages/linkifyjs/src/multi.mjs b/packages/linkifyjs/src/multi.mjs index 329bf8c..6d40bef 100644 --- a/packages/linkifyjs/src/multi.mjs +++ b/packages/linkifyjs/src/multi.mjs @@ -1,6 +1,5 @@ import { COLON, LOCALHOST } from './text.mjs'; import { defaults } from './options.mjs'; -import assign from './assign.mjs'; /****************************************************************************** Multi-Tokens @@ -163,7 +162,7 @@ MultiToken.prototype = { attributes.rel = rel; } if (attrs) { - assign(attributes, attrs); + Object.assign(attributes, attrs); } return { tagName, attributes, content, eventListeners }; diff --git a/packages/linkifyjs/src/options.mjs b/packages/linkifyjs/src/options.mjs index 9921b61..5604314 100644 --- a/packages/linkifyjs/src/options.mjs +++ b/packages/linkifyjs/src/options.mjs @@ -1,5 +1,3 @@ -import assign from './assign.mjs'; - /** * An object where each key is a valid DOM Event Name such as `click` or `focus` * and each value is an event handler function. @@ -109,9 +107,9 @@ export const defaults = { * Similar to render option */ export function Options(opts, defaultRender = null) { - let o = assign({}, defaults); + let o = Object.assign({}, defaults); if (opts) { - o = assign(o, opts instanceof Options ? opts.o : opts); + o = Object.assign(o, opts instanceof Options ? opts.o : opts); } // Ensure all ignored tags are uppercase @@ -214,8 +212,6 @@ Options.prototype = { }, }; -export { assign }; - function noop(val) { return val; } diff --git a/packages/linkifyjs/src/scanner.mjs b/packages/linkifyjs/src/scanner.mjs index 964b1e1..0b4988c 100644 --- a/packages/linkifyjs/src/scanner.mjs +++ b/packages/linkifyjs/src/scanner.mjs @@ -8,7 +8,6 @@ import { State, addToGroups, tr, ts, tt } from './fsm.mjs'; import * as fsm from './fsm.mjs'; import * as tk from './text.mjs'; import * as re from './regexp.mjs'; -import assign from './assign.mjs'; const CR = '\r'; // carriage-return character const LF = '\n'; // line-feed character @@ -203,7 +202,7 @@ export function init(customSchemes = []) { // Set default transition for start state (some symbol) Start.jd = new State(tk.SYM); - return { start: Start, tokens: assign({ groups }, tk) }; + return { start: Start, tokens: Object.assign({ groups }, tk) }; } /**