@@ -22,60 +22,7 @@ Original Code is the Ethereal Engine team.
2222All portions of the code written by the Ethereal Engine team are Copyright Β© 2021-2023
2323Ethereal Engine. All Rights Reserved.
2424*/
25-
26- export function insertSeparator ( children , separatorFn ) {
27- if ( ! Array . isArray ( children ) ) {
28- return children
29- }
30- const length = children . length
31- if ( length === 1 ) {
32- return children [ 0 ]
33- }
34- return children . reduce ( ( acc , item , index ) => {
35- acc . push ( item )
36- if ( index !== length - 1 ) {
37- acc . push ( separatorFn ( index ) )
38- }
39- return acc
40- } , [ ] )
41- }
42- export function objectToMap ( object : object ) {
43- return new Map ( Object . entries ( object ) )
44- }
45-
46- export const unique = < T , S = T > ( arr : T [ ] , keyFinder : ( item : T ) => S ) : T [ ] => {
47- const set = new Set < S > ( )
48- const newArr = [ ] as T [ ]
49- if ( ! keyFinder ) keyFinder = ( item : T ) => item as any as S
50-
51- for ( const item of arr ) {
52- const key = keyFinder ( item )
53- if ( set . has ( key ) ) continue
54-
55- newArr . push ( item )
56- set . add ( key )
57- }
58-
59- return newArr
60- }
61-
62- export const isApple = ( ) => {
63- if ( 'navigator' in globalThis === false ) return false
64-
65- const iOS_1to12 = / i P a d | i P h o n e | i P o d / . test ( navigator . platform )
66-
67- const iOS13_iPad = navigator . platform === 'MacIntel'
68-
69- const iOS1to12quirk = ( ) => {
70- const audio = new Audio ( ) // temporary Audio object
71- audio . volume = 0.5 // has no effect on iOS <= 12
72- return audio . volume === 1
73- }
74-
75- return iOS_1to12 || iOS13_iPad || iOS1to12quirk ( )
76- }
77-
78- export const cmdOrCtrlString = isApple ( ) ? 'meta' : 'ctrl'
25+ import { isApple } from '@etherealengine/common/src/utils/getDeviceStats'
7926
8027export function getStepSize ( event , smallStep , mediumStep , largeStep ) {
8128 if ( event . altKey ) {
@@ -86,29 +33,4 @@ export function getStepSize(event, smallStep, mediumStep, largeStep) {
8633 return mediumStep
8734}
8835
89- export function toPrecision ( value , precision ) {
90- const p = 1 / precision
91- return Math . round ( value * p ) / p
92- }
93- // https://stackoverflow.com/a/26188910
94- export function camelPad ( str ) {
95- return str
96- . replace ( / ( [ A - Z ] + ) ( [ A - Z ] [ a - z ] ) / g, ' $1 $2' )
97- . replace ( / ( [ a - z \d ] ) ( [ A - Z ] ) / g, '$1 $2' )
98- . replace ( / ( [ a - z A - Z ] ) ( \d ) / g, '$1 $2' )
99- . replace ( / ^ ./ , ( str ) => {
100- return str . toUpperCase ( )
101- } )
102- . trim ( )
103- }
104- export function bytesToSize ( bytes : number , decimals = 2 ) {
105- if ( bytes === 0 ) return '0 Bytes'
106-
107- const k = 1024
108- const dm = decimals < 0 ? 0 : decimals
109- const sizes = [ 'Bytes' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ]
110-
111- const i = Math . floor ( Math . log ( bytes ) / Math . log ( k ) )
112-
113- return parseFloat ( ( bytes / Math . pow ( k , i ) ) . toFixed ( dm ) ) + ' ' + sizes [ i ]
114- }
36+ export const cmdOrCtrlString = isApple ( ) ? 'meta' : 'ctrl'
0 commit comments