refactor: Use named exports instead of default exports (#2238)
* use named exports instead of default exports * fix tests Co-authored-by: Philipp Kühn <philippkuehn@MacBook-Pro-von-Philipp.local>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { MaybeReturnType } from '../types'
|
||||
import isFunction from './isFunction'
|
||||
import { isFunction } from './isFunction'
|
||||
|
||||
/**
|
||||
* Optionally calls `value` as a function.
|
||||
@@ -8,7 +8,7 @@ import isFunction from './isFunction'
|
||||
* @param context Optional context to bind to function.
|
||||
* @param props Optional props to pass to function.
|
||||
*/
|
||||
export default function callOrReturn<T>(value: T, context: any = undefined, ...props: any[]): MaybeReturnType<T> {
|
||||
export function callOrReturn<T>(value: T, context: any = undefined, ...props: any[]): MaybeReturnType<T> {
|
||||
if (isFunction(value)) {
|
||||
if (context) {
|
||||
return value.bind(context)(...props)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function createStyleTag(style: string): HTMLStyleElement {
|
||||
export function createStyleTag(style: string): HTMLStyleElement {
|
||||
const tipTapStyleTag = (<HTMLStyleElement>document.querySelector('style[data-tiptap-style]'))
|
||||
|
||||
if (tipTapStyleTag !== null) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @param obj Object
|
||||
* @param key Key to remove
|
||||
*/
|
||||
export default function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any> {
|
||||
export function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any> {
|
||||
const props = typeof propOrProps === 'string'
|
||||
? [propOrProps]
|
||||
: propOrProps
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function elementFromString(value: string): HTMLElement {
|
||||
export function elementFromString(value: string): HTMLElement {
|
||||
// add a wrapper to preserve leading and trailing whitespace
|
||||
const wrappedValue = `<body>${value}</body>`
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function findDuplicates(items: any[]): any[] {
|
||||
export function findDuplicates(items: any[]): any[] {
|
||||
const filtered = items.filter((el, index) => items.indexOf(el) !== index)
|
||||
|
||||
return [...new Set(filtered)]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function fromString(value: any): any {
|
||||
export function fromString(value: any): any {
|
||||
if (typeof value !== 'string') {
|
||||
return value
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function isClass(value: any): boolean {
|
||||
export function isClass(value: any): boolean {
|
||||
if (value.constructor?.toString().substring(0, 5) !== 'class') {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function isEmptyObject(value = {}): boolean {
|
||||
export function isEmptyObject(value = {}): boolean {
|
||||
return Object.keys(value).length === 0 && value.constructor === Object
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function isObject(value: any): value is Function {
|
||||
export function isFunction(value: any): value is Function {
|
||||
return typeof value === 'function'
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function isNumber(value: any): value is number {
|
||||
export function isNumber(value: any): value is number {
|
||||
return typeof value === 'number'
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import isClass from './isClass'
|
||||
import { isClass } from './isClass'
|
||||
|
||||
export default function isObject(value: any): boolean {
|
||||
export function isObject(value: any): boolean {
|
||||
return (
|
||||
value
|
||||
&& typeof value === 'object'
|
||||
|
||||
@@ -4,7 +4,7 @@ function getType(value: any): string {
|
||||
return Object.prototype.toString.call(value).slice(8, -1)
|
||||
}
|
||||
|
||||
export default function isPlainObject(value: any): value is Record<string, any> {
|
||||
export function isPlainObject(value: any): value is Record<string, any> {
|
||||
if (getType(value) !== 'Object') {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function isRegExp(value: any): value is RegExp {
|
||||
export function isRegExp(value: any): value is RegExp {
|
||||
return Object.prototype.toString.call(value) === '[object RegExp]'
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function isString(value: any): value is string {
|
||||
export function isString(value: any): value is string {
|
||||
return typeof value === 'string'
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function isiOS(): boolean {
|
||||
export function isiOS(): boolean {
|
||||
return [
|
||||
'iPad Simulator',
|
||||
'iPhone Simulator',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default function mergeAttributes(...objects: Record<string, any>[]): Record<string, any> {
|
||||
export function mergeAttributes(...objects: Record<string, any>[]): Record<string, any> {
|
||||
return objects
|
||||
.filter(item => !!item)
|
||||
.reduce((items, item) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import isPlainObject from './isPlainObject'
|
||||
import { isPlainObject } from './isPlainObject'
|
||||
|
||||
export default function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any> {
|
||||
export function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any> {
|
||||
const output = { ...target }
|
||||
|
||||
if (isPlainObject(target) && isPlainObject(source)) {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function minMax(value = 0, min = 0, max = 0): number {
|
||||
export function minMax(value = 0, min = 0, max = 0): number {
|
||||
return Math.min(Math.max(value, min), max)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import isRegExp from './isRegExp'
|
||||
import { isRegExp } from './isRegExp'
|
||||
|
||||
/**
|
||||
* Check if object1 includes object2
|
||||
* @param object1 Object
|
||||
* @param object2 Object
|
||||
*/
|
||||
export default function objectIncludes(
|
||||
export function objectIncludes(
|
||||
object1: Record<string, any>,
|
||||
object2: Record<string, any>,
|
||||
options: { strict: boolean } = { strict: true },
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Removes duplicated values within an array.
|
||||
* Supports numbers, strings and objects.
|
||||
*/
|
||||
export default function removeDuplicates<T>(array: T[], by = JSON.stringify): T[] {
|
||||
export function removeDuplicates<T>(array: T[], by = JSON.stringify): T[] {
|
||||
const seen: Record<any, any> = {}
|
||||
|
||||
return array.filter(item => {
|
||||
|
||||
Reference in New Issue
Block a user