import Case from 'case' ; import { MalVal , isKeyword } from '@/mal/types' ; import printExp from '@/mal/printer' ; import { Ref , unref } from '@vue/composition-api' ; export function replaceRange ( s , start , end , substitute ) { return [ s . substring ( 0 , start ) + substitute + s . substring ( end ) , start , end + ( substitute . length - ( end - start ) ) , ] ; } export function clamp ( value , min , max ) { return Math . max ( min , Math . min ( value , max ) ) ; } param exp export function getParamLabel ( exp ) { const str = isKeyword ( exp ) ? exp . slice ( 1 ) : printExp ( exp ) ; return str . length === 1 ? str : Case . capital ( str ) ; } /**
 * The utility class holds a value which does not need to be watched by Vue
 */ const ValueSymbol = Symbol ( 'NonReactive.value' ) ; export class NonReactive < T > { constructor ( value ) { ; ( this as any ) [ ValueSymbol ] = value ; } public get value ( ) : T { return ( this as any ) [ ValueSymbol ] ; } } /**
 * Creates NonReactive object
 */ export function nonReactive < T > ( value ) { return new NonReactive ( value ) ; } export function partition ( n , coll ) { const ret = [ ] ; for ( let i = 0 ; i < coll . length ; i += n ) { ret . push ( coll . slice ( i , i + n ) ) ; } return ret ; } export function delay ( ms ) { return new Promise ( resolve => setTimeout ( resolve , ms ) ) ; } export function getHTMLElement ( el ) { const _el = unref ( el ) ; return _el instanceof HTMLElement ? _el : _el instanceof Object && _el . $el instanceof HTMLElement ? _el . $el : undefined ; }