export const isRoot = ( ) => process . getuid && process . getuid ( ) === 0 ; export function isWindows ( ) { return ( process && ( process . platform === "win32" || /^(msys|cygwin)$/ . test ( process . env . OSTYPE + "" ) ) ) ; } export const wait = ( t ) => new Promise ( ( ok ) => setTimeout ( ok , t ) ) ; export const hang = ( ) => wait ( 999999999 ) ; export function narray ( count ) { return Array . from ( { length : count } , ( v , i ) => i ) ; } export function randomOne < T > ( items ) { return items [ Math . floor ( Math . random ( ) * items . length ) ] ; } export const getNodePath = ( ) => process . execPath ; param { Array } a export function shuffle < T > ( a ) { for ( let i = a . length - 1 ; i > 0 ; i -- ) { const j = Math . floor ( Math . random ( ) * ( i + 1 ) ) ; [ a [ i ] , a [ j ] ] = [ a [ j ] , a [ i ] ] ; } return a ; }