filer/dist/filer.map

1 line
377 KiB
Plaintext

{"version":3,"sources":["../lib/nodash.js","path.js","shared.js","constants.js","errors.js","../node_modules/node-libs-browser/node_modules/base64-js/index.js","../node_modules/ieee754/index.js","../node_modules/isarray/index.js","../node_modules/node-libs-browser/node_modules/buffer/index.js","buffer.js","providers/indexeddb.js","../node_modules/base64-arraybuffer/lib/base64-arraybuffer.js","providers/websql.js","../node_modules/node-libs-browser/node_modules/process/browser.js","../lib/async.js","providers/memory.js","providers/index.js","shell/environment.js","encoding.js","../node_modules/node-libs-browser/node_modules/path-browserify/index.js","../node_modules/concat-map/index.js","../node_modules/balanced-match/index.js","../node_modules/brace-expansion/index.js","../node_modules/minimatch/minimatch.js","shell/shell.js","../lib/eventemitter.js","../lib/intercom.js","fs-watcher.js","directory-entry.js","open-file-description.js","super-node.js","node.js","stats.js","filesystem/implementation.js","filesystem/interface.js","index.js"],"names":["ArrayProto","Array","prototype","nativeForEach","forEach","nativeIndexOf","indexOf","nativeSome","some","ObjProto","Object","hasOwnProperty","nativeKeys","keys","breaker","has","obj","key","call","TypeError","push","size","length","identity","value","each","iterator","context","i","any","result","index","list","contains","target","Wrapped","nodash","isArray","module","exports","normalizeArray","parts","allowAboveRoot","up","last","splice","unshift","splitPathRe","splitPath","filename","exec","resolve","resolvedPath","resolvedAbsolute","arguments","path","charAt","split","filter","p","join","normalize","isAbsolute","trailingSlash","substr","paths","slice","relative","from","to","trim","arr","start","end","fromParts","toParts","Math","min","samePartsLength","outputParts","concat","dirname","root","dir","basename","ext","f","extname","isNull","addTrailing","replace","removeTrailing","sep","delimiter","guid","c","r","random","v","toString","toUpperCase","nop","u8toArray","u8","array","len","O_READ","O_WRITE","O_CREATE","O_EXCLUSIVE","O_TRUNCATE","O_APPEND","XATTR_CREATE","XATTR_REPLACE","FILE_SYSTEM_NAME","FILE_STORE_NAME","IDB_RO","IDB_RW","WSQL_VERSION","WSQL_SIZE","WSQL_DESC","MODE_FILE","MODE_DIRECTORY","MODE_SYMBOLIC_LINK","MODE_META","SYMLOOP_MAX","BINARY_MIME_TYPE","JSON_MIME_TYPE","ROOT_DIRECTORY_NAME","FS_FORMAT","FS_NOCTIME","FS_NOMTIME","FS_NODUPEIDCHECK","O_FLAGS","FS_READY","FS_PENDING","FS_ERROR","SUPER_NODE_ID","STDIN","STDOUT","STDERR","FIRST_DESCRIPTOR","ENVIRONMENT","TMP","PATH","errors","e","errno","errName","defaultMessage","FilerError","msg","Error","name","code","message","stack","create","constructor","pathInfo","FilerBuffer","subject","encoding","nonZero","ArrayBuffer","Uint8Array","Buffer","require","Errors","indexedDB","global","mozIndexedDB","webkitIndexedDB","msIndexedDB","IndexedDBContext","db","mode","_getObjectStore","objectStore","transaction","clear","callback","request","onsuccess","onerror","event","preventDefault","error","err","_get","get","getObject","getBuffer","arrayBuffer","_put","put","putObject","putBuffer","uint8BackedBuffer","buf","buffer","delete","IndexedDB","isSupported","open","that","openRequest","onupgradeneeded","objectStoreNames","deleteObjectStore","createObjectStore","getReadOnlyContext","getReadWriteContext","chars","lookup","charCodeAt","encode","arraybuffer","bytes","base64","substring","decode","bufferLength","encoded1","encoded2","encoded3","encoded4","base64ArrayBuffer","WebSQLContext","isReadOnly","getTransaction","onError","onSuccess","executeSql","rows","item","data","JSON","parse","json","stringify","WebSQL","openDatabase","EINVAL","createIndex","process","cachedSetTimeout","cachedClearTimeout","defaultSetTimout","defaultClearTimeout","setTimeout","clearTimeout","runTimeout","fun","runClearTimeout","marker","queue","draining","currentQueue","queueIndex","cleanUpNextTick","drainQueue","timeout","run","nextTick","args","Item","apply","title","browser","env","argv","version","versions","noop","on","addListener","once","off","removeListener","removeAllListeners","emit","prependListener","prependOnceListener","listeners","binding","cwd","chdir","umask","async","setImmediate","fn","eachSeries","completed","iterate","forEachSeries","define","amd","asyncCallback","createDB","pool","getOrCreate","MemoryContext","readOnly","Memory","Default","Fallback","NotSupported","defaults","Environment","set","string","Path","Encoding","minimatch","Shell","fs","options","defineProperty","enumerable","cd","stat","stats","ENOTDIR","type","pwd","sh","readFile","cmd","Function","touch","createFile","writeFile","updateTimes","now","Date","atime","date","mtime","utimes","updateOnly","cat","files","all","append","ls","pathname","readdir","entries","getDirEntry","entry","links","nlinks","modified","recursive","items","contents","rm","remove","unlink","rmdir","ENOTEMPTY","map","tempDir","tmp","mkdir","mkdirp","_mkdirp","isDirectory","isFile","parent","find","next","found","processPath","maybeProcessPath","rawPath","regex","test","walk","removeItem","EventEmitter","createInterface","space","methods","trigger","self","pvt","_on","_off","_trigger","pub","throttle","delay","extend","a","b","localStorage","window","getItem","setItem","Intercom","origin","lastMessage","receivedIDs","previousValues","storageHandler","_onStorageEvent","document","attachEvent","addEventListener","_transaction","TIMEOUT","WAIT","executed","listening","waitTimer","lock","activeLock","INDEX_LOCK","unlock","_cleanup_emit","threshold","THRESHOLD_TTL_EMIT","changed","messages","INDEX_EMIT","timestamp","_cleanup_once","ttl","table","INDEX_ONCE","_once_expired","THRESHOLD_TTL_ONCE","_localStorageChanged","field","currentValue","id","payload","_emit","String","packet","supported","destroy","getInstance","intercom","FSWatcher","recursivePathPrefix","onchange","filename_","persistent_","recursive_","close","DirectoryEntry","OpenFileDescription","flags","position","getNode","check_if_node_exists","node","EBADF","Constants","SuperNode","ctime","rnode","Node","xattrs","blksize","undefined","nblocks","ensureID","prop","Stats","fileNode","devName","dev","isSymbolicLink","isSocket","isFIFO","isCharacterDevice","isBlockDevice","_","isAbsolutePath","isNullPath","update_node_times","times","update","complete","changes","make_node","parentPath","parentNode","parentNodeData","create_node_in_parent","parentDirectoryNode","find_node","EEXIST","ENOENT","create_node","update_parent_node_data","update_time","followedCount","read_root_directory_node","superNode","EFILESYSTEMERROR","check_root_directory_node","rootDirectoryNode","read_parent_directory_data","get_node_from_parent_directory_data","parentDirectoryData","nodeId","is_symbolic_link","ELOOP","follow_symbolic_link","set_extended_attribute","flag","ENOATTR","ensure_root_directory","directoryNode","directoryData","ensure_super_node","existingNode","write_directory_node","write_directory_data","make_directory","check_if_directory_exists","update_parent_directory_data","remove_directory","EBUSY","check_if_node_is_directory","check_if_directory_is_empty","remove_directory_entry_from_parent_directory_node","remove_directory_node","remove_directory_data","open_file","directoryEntry","fileData","EISDIR","set_file_node","read_directory_data","check_if_file_exists","check_if_symbolic_link","write_file_node","write_file_data","fill","update_directory_data","handle_update_result","replace_data","ofd","offset","return_nbytes","update_file_node","newData","copy","write_data","update_file_data","EIO","_position","newSize","max","read_file_data","read_data","handle_file_data","stat_file","fstat_file","lstat_file","link_node","oldpath","newpath","oldname","oldParentPath","newname","newParentPath","oldDirectoryNode","oldDirectoryData","newDirectoryNode","newDirectoryData","read_directory_entry","check_if_new_file_exists","read_new_directory_data","check_if_old_file_exists","EPERM","read_old_directory_data","unlink_node","delete_file_data","read_directory","handle_directory_data","make_symbolic_link","srcpath","dstpath","read_link","check_if_symbolic","truncate_file","truncate_file_data","ftruncate_file","utimes_file","update_times","futimes_file","setxattr_file","setxattr","fsetxattr_file","getxattr_file","get_xattr","fgetxattr_file","removexattr_file","remove_xattr","fremovexattr_file","validate_flags","validate_file_options","enc","fileMode","pathCheck","check_result","openFileDescription","fd","allocDescriptor","openFiles","releaseDescriptor","mknod","fstat","link","read","wrapped_cb","bytesRead","cleanup","fstatResult","nbytes","write","appendFile","exists","cb","getxattr","fgetxattr","fsetxattr","removexattr","fremovexattr","lseek","whence","update_descriptor_position","currentTime","futimes","rename","oldName","newName","oldParentDirectory","oldParentData","newParentDirectory","newParentData","newNode","read_new_directory","update_old_parent_directory_data","update_new_parent_directory_data","check_if_new_directory_exists","read_new_parent_directory_data","get_new_parent_directory","unlink_old_file","check_node_type","symlink","readlink","lstat","truncate","ftruncate","ensureRootDirectory","providers","defaultGuidFn","impl","maybeCallback","defaultCallback","console","FileSystem","provider","forceFormatting","readyState","stdin","stdout","stderr","bind","nextDescriptor","queueOrRun","operation","runQueued","watch","listener","watcher","wrappedGuidFn","guidWithCheck","broadcastChanges","change","wrappedContext","methodName","openReadWriteContext","openReadOnlyContext","l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AAsGAhH,OAAOC,OAAP,GAAiB0G,MAAjB;;ACvGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpFA;AACA;AACA;AACA;AACA;AACA;;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7vDA,SAASe,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AP;AACD,GAFD;;AAIA,OAAK6J,GAAL,GAAW,UAAS7J,IAAT,EAAejI,KAAf,EAAsB;AAC/BsP,QAAIrH,IAAJ,IAAYjI,KAAZ;AACD,GAFD;AAGD,CAZD;;;ACFA;AACA,SAASqM,MAAT,CAAgBtB,GAAhB,EAAqB;AACnB,SAAOA,IAAIpG,QAAJ,CAAa,MAAb,CAAP;AACD;;AAED,SAASqH,MAAT,CAAgB+F,MAAhB,EAAwB;AACtB,SAAO,IAAIjJ,MAAJ,CAAWiJ,MAAX,EAAmB,MAAnB,CAAP;AACD;;AAEDjR,OAAOC,OAAP,GAAiB;AACfiL,UAAQA,MADO;AAEfK,UAAQA;AAFO,CAAjB;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC35BA,IAAI2F,OAAOjJ,QAAQ,YAAR,CAAX;AACA,IAAIC,SAASD,QAAQ,cAAR,CAAb;AAC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er.map","sourceRoot":"../src","sourcesContent":["// Cherry-picked bits of underscore.js, lodash.js\n\n/**\n * Lo-Dash 2.4.0 <http://lodash.com/>\n * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>\n * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>\n * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * Available under MIT license <http://lodash.com/license>\n */\nvar ArrayProto = Array.prototype;\nvar nativeForEach = ArrayProto.forEach;\nvar nativeIndexOf = ArrayProto.indexOf;\nvar nativeSome = ArrayProto.some;\n\nvar ObjProto = Object.prototype;\nvar hasOwnProperty = ObjProto.hasOwnProperty;\nvar nativeKeys = Object.keys;\n\nvar breaker = {};\n\nfunction has(obj, key) {\n return hasOwnProperty.call(obj, key);\n}\n\nvar keys = nativeKeys || function(obj) {\n if (obj !== Object(obj)) throw new TypeError('Invalid object');\n var keys = [];\n for (var key in obj) if (has(obj, key)) keys.push(key);\n return keys;\n};\n\nfunction size(obj) {\n if (obj == null) return 0;\n return (obj.length === +obj.length) ? obj.length : keys(obj).length;\n}\n\nfunction identity(value) {\n return value;\n}\n\nfunction each(obj, iterator, context) {\n var i, length;\n if (obj == null) return;\n if (nativeForEach && obj.forEach === nativeForEach) {\n obj.forEach(iterator, context);\n } else if (obj.length === +obj.length) {\n for (i = 0, length = obj.length; i < length; i++) {\n if (iterator.call(context, obj[i], i, obj) === breaker) return;\n }\n } else {\n var keys = keys(obj);\n for (i = 0, length = keys.length; i < length; i++) {\n if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return;\n }\n }\n};\n\nfunction any(obj, iterator, context) {\n iterator || (iterator = identity);\n var result = false;\n if (obj == null) return result;\n if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);\n each(obj, function(value, index, list) {\n if (result || (result = iterator.call(context, value, index, list))) return breaker;\n });\n return !!result;\n};\n\nfunction contains(obj, target) {\n if (obj == null) return false;\n if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;\n return any(obj, function(value) {\n return value === target;\n });\n};\n\nfunction Wrapped(value) {\n this.value = value;\n}\nWrapped.prototype.has = function(key) {\n return has(this.value, key);\n};\nWrapped.prototype.contains = function(target) {\n return contains(this.value, target);\n};\nWrapped.prototype.size = function() {\n return size(this.value);\n};\n\nfunction nodash(value) {\n // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor\n return (value && typeof value == 'object' && !Array.isArray(value) && hasOwnProperty.call(value, '__wrapped__'))\n ? value\n : new Wrapped(value);\n}\n\nmodule.exports = nodash;\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// Based on https://github.com/joyent/node/blob/41e53e557992a7d552a8e23de035f9463da25c99/lib/path.js\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length - 1; i >= 0; i--) {\n var last = parts[i];\n if (last === '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Split a filename into [root, dir, basename, ext], unix version\n// 'root' is just a slash, or nothing.\nvar splitPathRe =\n /^(\\/?)([\\s\\S]+\\/(?!$)|\\/)?((?:\\.{1,2}$|[\\s\\S]+?)?(\\.[^.\\/]*)?)$/;\nvar splitPath = function(filename) {\n var result = splitPathRe.exec(filename);\n return [result[1] || '', result[2] || '', result[3] || '', result[4] || ''];\n};\n\n// path.resolve([from ...], to)\nfunction resolve() {\n var resolvedPath = '',\n resolvedAbsolute = false;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n // XXXfiler: we don't have process.cwd() so we use '/' as a fallback\n var path = (i >= 0) ? arguments[i] : '/';\n\n // Skip empty and invalid entries\n if (typeof path !== 'string' || !path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(resolvedPath.split('/').filter(function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n}\n\n// path.normalize(path)\nfunction normalize(path) {\n var isAbsolute = path.charAt(0) === '/',\n trailingSlash = path.substr(-1) === '/';\n\n // Normalize the path\n path = normalizeArray(path.split('/').filter(function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n /*\n if (path && trailingSlash) {\n path += '/';\n }\n */\n\n return (isAbsolute ? '/' : '') + path;\n}\n\nfunction join() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return normalize(paths.filter(function(p, index) {\n return p && typeof p === 'string';\n }).join('/'));\n}\n\n// path.relative(from, to)\nfunction relative(from, to) {\n from = resolve(from).substr(1);\n to = resolve(to).substr(1);\n\n function trim(arr) {\n var start = 0;\n for (; start < arr.length; start++) {\n if (arr[start] !== '') break;\n }\n\n var end = arr.length - 1;\n for (; end >= 0; end--) {\n if (arr[end] !== '') break;\n }\n\n if (start > end) return [];\n return arr.slice(start, end - start + 1);\n }\n\n var fromParts = trim(from.split('/'));\n var toParts = trim(to.split('/'));\n\n var length = Math.min(fromParts.length, toParts.length);\n var samePartsLength = length;\n for (var i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i;\n break;\n }\n }\n\n var outputParts = [];\n for (var i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..');\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\n\n return outputParts.join('/');\n}\n\nfunction dirname(path) {\n var result = splitPath(path),\n root = result[0],\n dir = result[1];\n\n if (!root && !dir) {\n // No dirname whatsoever\n return '.';\n }\n\n if (dir) {\n // It has a dirname, strip trailing slash\n dir = dir.substr(0, dir.length - 1);\n }\n\n return root + dir;\n}\n\nfunction basename(path, ext) {\n var f = splitPath(path)[2];\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n // XXXfiler: node.js just does `return f`\n return f === \"\" ? \"/\" : f;\n}\n\nfunction extname(path) {\n return splitPath(path)[3];\n}\n\nfunction isAbsolute(path) {\n if(path.charAt(0) === '/') {\n return true;\n }\n return false;\n}\n\nfunction isNull(path) {\n if (('' + path).indexOf('\\u0000') !== -1) {\n return true;\n }\n return false;\n}\n\n// Make sure we don't double-add a trailing slash (e.g., '/' -> '//')\nfunction addTrailing(path) {\n return path.replace(/\\/*$/, '/');\n}\n\n// Deal with multiple slashes at the end, one, or none\n// and make sure we don't return the empty string.\nfunction removeTrailing(path) {\n path = path.replace(/\\/*$/, '');\n return path === '' ? '/' : path;\n}\n\n// XXXfiler: we don't support path.exists() or path.existsSync(), which\n// are deprecated, and need a FileSystem instance to work. Use fs.stat().\n\nmodule.exports = {\n normalize: normalize,\n resolve: resolve,\n join: join,\n relative: relative,\n sep: '/',\n delimiter: ':',\n dirname: dirname,\n basename: basename,\n extname: extname,\n isAbsolute: isAbsolute,\n isNull: isNull,\n // Non-node but useful...\n addTrailing: addTrailing,\n removeTrailing: removeTrailing\n};\n","function guid() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);\n return v.toString(16);\n }).toUpperCase();\n}\n\nfunction nop() {}\n\n/**\n * Convert a Uint8Array to a regular array\n */\nfunction u8toArray(u8) {\n var array = [];\n var len = u8.length;\n for(var i = 0; i < len; i++) {\n array[i] = u8[i];\n }\n return array;\n}\n\nmodule.exports = {\n guid: guid,\n u8toArray: u8toArray,\n nop: nop\n};\n","var O_READ = 'READ';\nvar O_WRITE = 'WRITE';\nvar O_CREATE = 'CREATE';\nvar O_EXCLUSIVE = 'EXCLUSIVE';\nvar O_TRUNCATE = 'TRUNCATE';\nvar O_APPEND = 'APPEND';\nvar XATTR_CREATE = 'CREATE';\nvar XATTR_REPLACE = 'REPLACE';\n\nmodule.exports = {\n FILE_SYSTEM_NAME: 'local',\n\n FILE_STORE_NAME: 'files',\n\n IDB_RO: 'readonly',\n IDB_RW: 'readwrite',\n\n WSQL_VERSION: \"1\",\n WSQL_SIZE: 5 * 1024 * 1024,\n WSQL_DESC: \"FileSystem Storage\",\n\n MODE_FILE: 'FILE',\n MODE_DIRECTORY: 'DIRECTORY',\n MODE_SYMBOLIC_LINK: 'SYMLINK',\n MODE_META: 'META',\n\n SYMLOOP_MAX: 10,\n\n BINARY_MIME_TYPE: 'application/octet-stream',\n JSON_MIME_TYPE: 'application/json',\n\n ROOT_DIRECTORY_NAME: '/', // basename(normalize(path))\n\n // FS Mount Flags\n FS_FORMAT: 'FORMAT',\n FS_NOCTIME: 'NOCTIME',\n FS_NOMTIME: 'NOMTIME',\n FS_NODUPEIDCHECK: 'FS_NODUPEIDCHECK',\n\n // FS File Open Flags\n O_READ: O_READ,\n O_WRITE: O_WRITE,\n O_CREATE: O_CREATE,\n O_EXCLUSIVE: O_EXCLUSIVE,\n O_TRUNCATE: O_TRUNCATE,\n O_APPEND: O_APPEND,\n\n O_FLAGS: {\n 'r': [O_READ],\n 'r+': [O_READ, O_WRITE],\n 'w': [O_WRITE, O_CREATE, O_TRUNCATE],\n 'w+': [O_WRITE, O_READ, O_CREATE, O_TRUNCATE],\n 'wx': [O_WRITE, O_CREATE, O_EXCLUSIVE, O_TRUNCATE],\n 'wx+': [O_WRITE, O_READ, O_CREATE, O_EXCLUSIVE, O_TRUNCATE],\n 'a': [O_WRITE, O_CREATE, O_APPEND],\n 'a+': [O_WRITE, O_READ, O_CREATE, O_APPEND],\n 'ax': [O_WRITE, O_CREATE, O_EXCLUSIVE, O_APPEND],\n 'ax+': [O_WRITE, O_READ, O_CREATE, O_EXCLUSIVE, O_APPEND]\n },\n\n XATTR_CREATE: XATTR_CREATE,\n XATTR_REPLACE: XATTR_REPLACE,\n\n FS_READY: 'READY',\n FS_PENDING: 'PENDING',\n FS_ERROR: 'ERROR',\n\n SUPER_NODE_ID: '00000000-0000-0000-0000-000000000000',\n\n // Reserved File Descriptors for streams\n STDIN: 0,\n STDOUT: 1,\n STDERR: 2,\n FIRST_DESCRIPTOR: 3,\n\n ENVIRONMENT: {\n TMP: '/tmp',\n PATH: ''\n }\n};\n","var errors = {};\n[\n /**\n * node.js errors - we only use some of these, add as needed.\n */\n //'-1:UNKNOWN:unknown error',\n //'0:OK:success',\n //'1:EOF:end of file',\n //'2:EADDRINFO:getaddrinfo error',\n //'3:EACCES:permission denied',\n //'4:EAGAIN:resource temporarily unavailable',\n //'5:EADDRINUSE:address already in use',\n //'6:EADDRNOTAVAIL:address not available',\n //'7:EAFNOSUPPORT:address family not supported',\n //'8:EALREADY:connection already in progress',\n '9:EBADF:bad file descriptor',\n '10:EBUSY:resource busy or locked',\n //'11:ECONNABORTED:software caused connection abort',\n //'12:ECONNREFUSED:connection refused',\n //'13:ECONNRESET:connection reset by peer',\n //'14:EDESTADDRREQ:destination address required',\n //'15:EFAULT:bad address in system call argument',\n //'16:EHOSTUNREACH:host is unreachable',\n //'17:EINTR:interrupted system call',\n '18:EINVAL:invalid argument',\n //'19:EISCONN:socket is already connected',\n //'20:EMFILE:too many open files',\n //'21:EMSGSIZE:message too long',\n //'22:ENETDOWN:network is down',\n //'23:ENETUNREACH:network is unreachable',\n //'24:ENFILE:file table overflow',\n //'25:ENOBUFS:no buffer space available',\n //'26:ENOMEM:not enough memory',\n '27:ENOTDIR:not a directory',\n '28:EISDIR:illegal operation on a directory',\n //'29:ENONET:machine is not on the network',\n // errno 30 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js\n //'31:ENOTCONN:socket is not connected',\n //'32:ENOTSOCK:socket operation on non-socket',\n //'33:ENOTSUP:operation not supported on socket',\n '34:ENOENT:no such file or directory',\n //'35:ENOSYS:function not implemented',\n //'36:EPIPE:broken pipe',\n //'37:EPROTO:protocol error',\n //'38:EPROTONOSUPPORT:protocol not supported',\n //'39:EPROTOTYPE:protocol wrong type for socket',\n //'40:ETIMEDOUT:connection timed out',\n //'41:ECHARSET:invalid Unicode character',\n //'42:EAIFAMNOSUPPORT:address family for hostname not supported',\n // errno 43 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js\n //'44:EAISERVICE:servname not supported for ai_socktype',\n //'45:EAISOCKTYPE:ai_socktype not supported',\n //'46:ESHUTDOWN:cannot send after transport endpoint shutdown',\n '47:EEXIST:file already exists',\n //'48:ESRCH:no such process',\n //'49:ENAMETOOLONG:name too long',\n '50:EPERM:operation not permitted',\n '51:ELOOP:too many symbolic links encountered',\n //'52:EXDEV:cross-device link not permitted',\n '53:ENOTEMPTY:directory not empty',\n //'54:ENOSPC:no space left on device',\n '55:EIO:i/o error',\n //'56:EROFS:read-only file system',\n //'57:ENODEV:no such device',\n //'58:ESPIPE:invalid seek',\n //'59:ECANCELED:operation canceled',\n\n /**\n * Filer specific errors\n */\n '1000:ENOTMOUNTED:not mounted',\n '1001:EFILESYSTEMERROR:missing super node, use \\'FORMAT\\' flag to format filesystem.',\n '1002:ENOATTR:attribute does not exist'\n\n].forEach(function(e) {\n e = e.split(':');\n var errno = +e[0];\n var errName = e[1];\n var defaultMessage = e[2];\n\n function FilerError(msg, path) {\n Error.call(this);\n\n this.name = errName;\n this.code = errName;\n this.errno = errno;\n this.message = msg || defaultMessage;\n if(path) {\n this.path = path;\n }\n this.stack = (new Error(this.message)).stack;\n }\n FilerError.prototype = Object.create(Error.prototype);\n FilerError.prototype.constructor = FilerError;\n FilerError.prototype.toString = function() {\n var pathInfo = this.path ? (', \\'' + this.path + '\\'') : '';\n return this.name + ': ' + this.message + pathInfo;\n };\n\n // We expose the error as both Errors.EINVAL and Errors[18]\n errors[errName] = errors[errno] = FilerError;\n});\n\nmodule.exports = errors;\n","'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n for (var i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>\n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\nvar isArray = require('isarray')\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return '<Buffer ' + str + '>'\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n","function FilerBuffer (subject, encoding, nonZero) {\n\n // Automatically turn ArrayBuffer into Uint8Array so that underlying\n // Buffer code doesn't just throw away and ignore ArrayBuffer data.\n if (subject instanceof ArrayBuffer) {\n subject = new Uint8Array(subject);\n }\n\n return new Buffer(subject, encoding, nonZero);\n};\n\n// Inherit prototype from Buffer\nFilerBuffer.prototype = Object.create(Buffer.prototype);\nFilerBuffer.prototype.constructor = FilerBuffer;\n\n// Also copy static methods onto FilerBuffer ctor\nObject.keys(Buffer).forEach(function (p) {\n if (Buffer.hasOwnProperty(p)) {\n FilerBuffer[p] = Buffer[p];\n }\n});\n\nmodule.exports = FilerBuffer;\n","var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME;\nvar FILE_STORE_NAME = require('../constants.js').FILE_STORE_NAME;\nvar IDB_RW = require('../constants.js').IDB_RW;\nvar IDB_RO = require('../constants.js').IDB_RO;\nvar Errors = require('../errors.js');\nvar FilerBuffer = require('../buffer.js');\n\nvar indexedDB = global.indexedDB ||\n global.mozIndexedDB ||\n global.webkitIndexedDB ||\n global.msIndexedDB;\n\nfunction IndexedDBContext(db, mode) {\n this.db = db;\n this.mode = mode;\n}\n\nIndexedDBContext.prototype._getObjectStore = function() {\n if(this.objectStore) {\n return this.objectStore;\n }\n\n var transaction = this.db.transaction(FILE_STORE_NAME, this.mode);\n this.objectStore = transaction.objectStore(FILE_STORE_NAME);\n return this.objectStore;\n};\n\nIndexedDBContext.prototype.clear = function(callback) {\n try {\n var objectStore = this._getObjectStore();\n var request = objectStore.clear();\n request.onsuccess = function() {\n callback();\n };\n request.onerror = function(event) {\n event.preventDefault();\n callback(event.error);\n };\n } catch(err) {\n callback(err);\n }\n};\n\nIndexedDBContext.prototype._get = function(key, callback) {\n try {\n var objectStore = this._getObjectStore();\n var request = objectStore.get(key);\n request.onsuccess = function onsuccess(event) {\n var result = event.target.result;\n callback(null, result);\n };\n request.onerror = function(event) {\n event.preventDefault();\n callback(event.error);\n };\n } catch(err) {\n callback(err);\n }\n};\nIndexedDBContext.prototype.getObject = function(key, callback) {\n this._get(key, callback);\n};\nIndexedDBContext.prototype.getBuffer = function(key, callback) {\n this._get(key, function(err, arrayBuffer) {\n if(err) {\n return callback(err);\n }\n callback(null, new FilerBuffer(arrayBuffer));\n });\n};\n\nIndexedDBContext.prototype._put = function(key, value, callback) {\n try {\n var objectStore = this._getObjectStore();\n var request = objectStore.put(value, key);\n request.onsuccess = function onsuccess(event) {\n var result = event.target.result;\n callback(null, result);\n };\n request.onerror = function(event) {\n event.preventDefault();\n callback(event.error);\n };\n } catch(err) {\n callback(err);\n }\n};\nIndexedDBContext.prototype.putObject = function(key, value, callback) {\n this._put(key, value, callback);\n};\nIndexedDBContext.prototype.putBuffer = function(key, uint8BackedBuffer, callback) {\n var buf = uint8BackedBuffer.buffer;\n this._put(key, buf, callback);\n};\n\nIndexedDBContext.prototype.delete = function(key, callback) {\n try {\n var objectStore = this._getObjectStore();\n var request = objectStore.delete(key);\n request.onsuccess = function onsuccess(event) {\n var result = event.target.result;\n callback(null, result);\n };\n request.onerror = function(event) {\n event.preventDefault();\n callback(event.error);\n };\n } catch(err) {\n callback(err);\n }\n};\n\n\nfunction IndexedDB(name) {\n this.name = name || FILE_SYSTEM_NAME;\n this.db = null;\n}\nIndexedDB.isSupported = function() {\n return !!indexedDB;\n};\n\nIndexedDB.prototype.open = function(callback) {\n var that = this;\n\n // Bail if we already have a db open\n if(that.db) {\n return callback();\n }\n\n try {\n // NOTE: we're not using versioned databases.\n var openRequest = indexedDB.open(that.name);\n\n // If the db doesn't exist, we'll create it\n openRequest.onupgradeneeded = function onupgradeneeded(event) {\n var db = event.target.result;\n\n if(db.objectStoreNames.contains(FILE_STORE_NAME)) {\n db.deleteObjectStore(FILE_STORE_NAME);\n }\n db.createObjectStore(FILE_STORE_NAME);\n };\n\n openRequest.onsuccess = function onsuccess(event) {\n that.db = event.target.result;\n callback();\n };\n openRequest.onerror = function onerror(event) {\n event.preventDefault();\n callback(event.error);\n };\n } catch(err) {\n callback(err);\n }\n};\n\nIndexedDB.prototype.getReadOnlyContext = function() {\n return new IndexedDBContext(this.db, IDB_RO);\n};\nIndexedDB.prototype.getReadWriteContext = function() {\n return new IndexedDBContext(this.db, IDB_RW);\n};\n\nmodule.exports = IndexedDB;\n","/*\n * base64-arraybuffer\n * https://github.com/niklasvh/base64-arraybuffer\n *\n * Copyright (c) 2012 Niklas von Hertzen\n * Licensed under the MIT license.\n */\n(function(){\n \"use strict\";\n\n var chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n // Use a lookup table to find the index.\n var lookup = new Uint8Array(256);\n for (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n }\n\n exports.encode = function(arraybuffer) {\n var bytes = new Uint8Array(arraybuffer),\n i, len = bytes.length, base64 = \"\";\n\n for (i = 0; i < len; i+=3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n\n if ((len % 3) === 2) {\n base64 = base64.substring(0, base64.length - 1) + \"=\";\n } else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + \"==\";\n }\n\n return base64;\n };\n\n exports.decode = function(base64) {\n var bufferLength = base64.length * 0.75,\n len = base64.length, i, p = 0,\n encoded1, encoded2, encoded3, encoded4;\n\n if (base64[base64.length - 1] === \"=\") {\n bufferLength--;\n if (base64[base64.length - 2] === \"=\") {\n bufferLength--;\n }\n }\n\n var arraybuffer = new ArrayBuffer(bufferLength),\n bytes = new Uint8Array(arraybuffer);\n\n for (i = 0; i < len; i+=4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i+1)];\n encoded3 = lookup[base64.charCodeAt(i+2)];\n encoded4 = lookup[base64.charCodeAt(i+3)];\n\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n\n return arraybuffer;\n };\n})();\n","var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME;\nvar FILE_STORE_NAME = require('../constants.js').FILE_STORE_NAME;\nvar WSQL_VERSION = require('../constants.js').WSQL_VERSION;\nvar WSQL_SIZE = require('../constants.js').WSQL_SIZE;\nvar WSQL_DESC = require('../constants.js').WSQL_DESC;\nvar Errors = require('../errors.js');\nvar FilerBuffer = require('../buffer.js');\nvar base64ArrayBuffer = require('base64-arraybuffer');\n\nfunction WebSQLContext(db, isReadOnly) {\n var that = this;\n this.getTransaction = function(callback) {\n if(that.transaction) {\n callback(that.transaction);\n return;\n }\n // Either do readTransaction() (read-only) or transaction() (read/write)\n db[isReadOnly ? 'readTransaction' : 'transaction'](function(transaction) {\n that.transaction = transaction;\n callback(transaction);\n });\n };\n}\n\nWebSQLContext.prototype.clear = function(callback) {\n function onError(transaction, error) {\n callback(error);\n }\n function onSuccess(transaction, result) {\n callback(null);\n }\n this.getTransaction(function(transaction) {\n transaction.executeSql(\"DELETE FROM \" + FILE_STORE_NAME + \";\",\n [], onSuccess, onError);\n });\n};\n\nfunction _get(getTransaction, key, callback) {\n function onSuccess(transaction, result) {\n // If the key isn't found, return null\n var value = result.rows.length === 0 ? null : result.rows.item(0).data;\n callback(null, value);\n }\n function onError(transaction, error) {\n callback(error);\n }\n getTransaction(function(transaction) {\n transaction.executeSql(\"SELECT data FROM \" + FILE_STORE_NAME + \" WHERE id = ? LIMIT 1;\",\n [key], onSuccess, onError);\n });\n}\nWebSQLContext.prototype.getObject = function(key, callback) {\n _get(this.getTransaction, key, function(err, result) {\n if(err) {\n return callback(err);\n }\n\n try {\n if(result) {\n result = JSON.parse(result);\n }\n } catch(e) {\n return callback(e);\n }\n\n callback(null, result);\n });\n};\nWebSQLContext.prototype.getBuffer = function(key, callback) {\n _get(this.getTransaction, key, function(err, result) {\n if(err) {\n return callback(err);\n }\n\n // Deal with zero-length ArrayBuffers, which will be encoded as ''\n if(result || result === '') {\n var arrayBuffer = base64ArrayBuffer.decode(result);\n result = new FilerBuffer(arrayBuffer);\n }\n\n callback(null, result);\n });\n};\n\nfunction _put(getTransaction, key, value, callback) {\n function onSuccess(transaction, result) {\n callback(null);\n }\n function onError(transaction, error) {\n callback(error);\n }\n getTransaction(function(transaction) {\n transaction.executeSql(\"INSERT OR REPLACE INTO \" + FILE_STORE_NAME + \" (id, data) VALUES (?, ?);\",\n [key, value], onSuccess, onError);\n });\n}\nWebSQLContext.prototype.putObject = function(key, value, callback) {\n var json = JSON.stringify(value);\n _put(this.getTransaction, key, json, callback);\n};\nWebSQLContext.prototype.putBuffer = function(key, uint8BackedBuffer, callback) {\n var base64 = base64ArrayBuffer.encode(uint8BackedBuffer.buffer);\n _put(this.getTransaction, key, base64, callback);\n};\n\nWebSQLContext.prototype.delete = function(key, callback) {\n function onSuccess(transaction, result) {\n callback(null);\n }\n function onError(transaction, error) {\n callback(error);\n }\n this.getTransaction(function(transaction) {\n transaction.executeSql(\"DELETE FROM \" + FILE_STORE_NAME + \" WHERE id = ?;\",\n [key], onSuccess, onError);\n });\n};\n\n\nfunction WebSQL(name) {\n this.name = name || FILE_SYSTEM_NAME;\n this.db = null;\n}\nWebSQL.isSupported = function() {\n return !!global.openDatabase;\n};\n\nWebSQL.prototype.open = function(callback) {\n var that = this;\n\n // Bail if we already have a db open\n if(that.db) {\n return callback();\n }\n\n var db = global.openDatabase(that.name, WSQL_VERSION, WSQL_DESC, WSQL_SIZE);\n if(!db) {\n callback(\"[WebSQL] Unable to open database.\");\n return;\n }\n\n function onError(transaction, error) {\n if (error.code === 5) {\n callback(new Errors.EINVAL('WebSQL cannot be accessed. If private browsing is enabled, disable it.'));\n }\n callback(error);\n }\n function onSuccess(transaction, result) {\n that.db = db;\n callback();\n }\n\n // Create the table and index we'll need to store the fs data.\n db.transaction(function(transaction) {\n function createIndex(transaction) {\n transaction.executeSql(\"CREATE INDEX IF NOT EXISTS idx_\" + FILE_STORE_NAME + \"_id\" +\n \" on \" + FILE_STORE_NAME + \" (id);\",\n [], onSuccess, onError);\n }\n transaction.executeSql(\"CREATE TABLE IF NOT EXISTS \" + FILE_STORE_NAME + \" (id unique, data TEXT);\",\n [], createIndex, onError);\n });\n};\nWebSQL.prototype.getReadOnlyContext = function() {\n return new WebSQLContext(this.db, true);\n};\nWebSQL.prototype.getReadWriteContext = function() {\n return new WebSQLContext(this.db, false);\n};\n\nmodule.exports = WebSQL;\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","/*global setImmediate: false, setTimeout: false, console: false */\n\n/**\n * async.js shim, based on https://raw.github.com/caolan/async/master/lib/async.js Feb 18, 2014\n * Used under MIT - https://github.com/caolan/async/blob/master/LICENSE\n */\n\n(function () {\n\n var async = {};\n\n // async.js functions used in Filer\n\n //// nextTick implementation with browser-compatible fallback ////\n if (typeof process === 'undefined' || !(process.nextTick)) {\n if (typeof setImmediate === 'function') {\n async.nextTick = function (fn) {\n // not a direct alias for IE10 compatibility\n setImmediate(fn);\n };\n async.setImmediate = async.nextTick;\n }\n else {\n async.nextTick = function (fn) {\n setTimeout(fn, 0);\n };\n async.setImmediate = async.nextTick;\n }\n }\n else {\n async.nextTick = process.nextTick;\n if (typeof setImmediate !== 'undefined') {\n async.setImmediate = function (fn) {\n // not a direct alias for IE10 compatibility\n setImmediate(fn);\n };\n }\n else {\n async.setImmediate = async.nextTick;\n }\n }\n\n async.eachSeries = function (arr, iterator, callback) {\n callback = callback || function () {};\n if (!arr.length) {\n return callback();\n }\n var completed = 0;\n var iterate = function () {\n iterator(arr[completed], function (err) {\n if (err) {\n callback(err);\n callback = function () {};\n }\n else {\n completed += 1;\n if (completed >= arr.length) {\n callback();\n }\n else {\n iterate();\n }\n }\n });\n };\n iterate();\n };\n async.forEachSeries = async.eachSeries;\n\n // AMD / RequireJS\n if (typeof define !== 'undefined' && define.amd) {\n define([], function () {\n return async;\n });\n }\n // Node.js\n else if (typeof module !== 'undefined' && module.exports) {\n module.exports = async;\n }\n // included directly via <script> tag\n else {\n root.async = async;\n }\n\n}());\n","var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME;\n// NOTE: prefer setImmediate to nextTick for proper recursion yielding.\n// see https://github.com/js-platform/filer/pull/24\nvar asyncCallback = require('../../lib/async.js').setImmediate;\n\n/**\n * Make shared in-memory DBs possible when using the same name.\n */\nvar createDB = (function() {\n var pool = {};\n return function getOrCreate(name) {\n if(!pool.hasOwnProperty(name)) {\n pool[name] = {};\n }\n return pool[name];\n };\n}());\n\nfunction MemoryContext(db, readOnly) {\n this.readOnly = readOnly;\n this.objectStore = db;\n}\n\nMemoryContext.prototype.clear = function(callback) {\n if(this.readOnly) {\n asyncCallback(function() {\n callback(\"[MemoryContext] Error: write operation on read only context\");\n });\n return;\n }\n var objectStore = this.objectStore;\n Object.keys(objectStore).forEach(function(key){\n delete objectStore[key];\n });\n asyncCallback(callback);\n};\n\n// Memory context doesn't care about differences between Object and Buffer\nMemoryContext.prototype.getObject =\nMemoryContext.prototype.getBuffer =\nfunction(key, callback) {\n var that = this;\n asyncCallback(function() {\n callback(null, that.objectStore[key]);\n });\n};\nMemoryContext.prototype.putObject =\nMemoryContext.prototype.putBuffer =\nfunction(key, value, callback) {\n if(this.readOnly) {\n asyncCallback(function() {\n callback(\"[MemoryContext] Error: write operation on read only context\");\n });\n return;\n }\n this.objectStore[key] = value;\n asyncCallback(callback);\n};\n\nMemoryContext.prototype.delete = function(key, callback) {\n if(this.readOnly) {\n asyncCallback(function() {\n callback(\"[MemoryContext] Error: write operation on read only context\");\n });\n return;\n }\n delete this.objectStore[key];\n asyncCallback(callback);\n};\n\n\nfunction Memory(name) {\n this.name = name || FILE_SYSTEM_NAME;\n}\nMemory.isSupported = function() {\n return true;\n};\n\nMemory.prototype.open = function(callback) {\n this.db = createDB(this.name);\n asyncCallback(callback);\n};\nMemory.prototype.getReadOnlyContext = function() {\n return new MemoryContext(this.db, true);\n};\nMemory.prototype.getReadWriteContext = function() {\n return new MemoryContext(this.db, false);\n};\n\nmodule.exports = Memory;\n","var IndexedDB = require('./indexeddb.js');\nvar WebSQL = require('./websql.js');\nvar Memory = require('./memory.js');\n\nmodule.exports = {\n IndexedDB: IndexedDB,\n WebSQL: WebSQL,\n Memory: Memory,\n\n /**\n * Convenience Provider references\n */\n\n // The default provider to use when none is specified\n Default: IndexedDB,\n\n // The Fallback provider does automatic fallback checks\n Fallback: (function() {\n if(IndexedDB.isSupported()) {\n return IndexedDB;\n }\n\n if(WebSQL.isSupported()) {\n return WebSQL;\n }\n\n function NotSupported() {\n throw \"[Filer Error] Your browser doesn't support IndexedDB or WebSQL.\";\n }\n NotSupported.isSupported = function() {\n return false;\n };\n return NotSupported;\n }())\n};\n","var defaults = require('../constants.js').ENVIRONMENT;\n\nmodule.exports = function Environment(env) {\n env = env || {};\n env.TMP = env.TMP || defaults.TMP;\n env.PATH = env.PATH || defaults.PATH;\n\n this.get = function(name) {\n return env[name];\n };\n\n this.set = function(name, value) {\n env[name] = value;\n };\n};\n","// Adapt encodings to work with Buffer or Uint8Array, they expect the latter\nfunction decode(buf) {\n return buf.toString('utf8');\n}\n\nfunction encode(string) {\n return new Buffer(string, 'utf8');\n}\n\nmodule.exports = {\n encode: encode,\n decode: decode\n};\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length - 1; i >= 0; i--) {\n var last = parts[i];\n if (last === '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Split a filename into [root, dir, basename, ext], unix version\n// 'root' is just a slash, or nothing.\nvar splitPathRe =\n /^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;\nvar splitPath = function(filename) {\n return splitPathRe.exec(filename).slice(1);\n};\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\n var resolvedPath = '',\n resolvedAbsolute = false;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0) ? arguments[i] : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string') {\n throw new TypeError('Arguments to path.resolve must be strings');\n } else if (!path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\n var isAbsolute = exports.isAbsolute(path),\n trailingSlash = substr(path, -1) === '/';\n\n // Normalize the path\n path = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n\n return (isAbsolute ? '/' : '') + path;\n};\n\n// posix version\nexports.isAbsolute = function(path) {\n return path.charAt(0) === '/';\n};\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n if (typeof p !== 'string') {\n throw new TypeError('Arguments to path.join must be strings');\n }\n return p;\n }).join('/'));\n};\n\n\n// path.relative(from, to)\n// posix version\nexports.relative = function(from, to) {\n from = exports.resolve(from).substr(1);\n to = exports.resolve(to).substr(1);\n\n function trim(arr) {\n var start = 0;\n for (; start < arr.length; start++) {\n if (arr[start] !== '') break;\n }\n\n var end = arr.length - 1;\n for (; end >= 0; end--) {\n if (arr[end] !== '') break;\n }\n\n if (start > end) return [];\n return arr.slice(start, end - start + 1);\n }\n\n var fromParts = trim(from.split('/'));\n var toParts = trim(to.split('/'));\n\n var length = Math.min(fromParts.length, toParts.length);\n var samePartsLength = length;\n for (var i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i;\n break;\n }\n }\n\n var outputParts = [];\n for (var i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..');\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\n\n return outputParts.join('/');\n};\n\nexports.sep = '/';\nexports.delimiter = ':';\n\nexports.dirname = function(path) {\n var result = splitPath(path),\n root = result[0],\n dir = result[1];\n\n if (!root && !dir) {\n // No dirname whatsoever\n return '.';\n }\n\n if (dir) {\n // It has a dirname, strip trailing slash\n dir = dir.substr(0, dir.length - 1);\n }\n\n return root + dir;\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPath(path)[2];\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPath(path)[3];\n};\n\nfunction filter (xs, f) {\n if (xs.filter) return xs.filter(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (f(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// String.prototype.substr - negative index don't work in IE8\nvar substr = 'ab'.substr(-1) === 'b'\n ? function (str, start, len) { return str.substr(start, len) }\n : function (str, start, len) {\n if (start < 0) start = str.length + start;\n return str.substr(start, len);\n }\n;\n","module.exports = function (xs, fn) {\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n var x = fn(xs[i], i);\n if (isArray(x)) res.push.apply(res, x);\n else res.push(x);\n }\n return res;\n};\n\nvar isArray = Array.isArray || function (xs) {\n return Object.prototype.toString.call(xs) === '[object Array]';\n};\n","'use strict';\nmodule.exports = balanced;\nfunction balanced(a, b, str) {\n if (a instanceof RegExp) a = maybeMatch(a, str);\n if (b instanceof RegExp) b = maybeMatch(b, str);\n\n var r = range(a, b, str);\n\n return r && {\n start: r[0],\n end: r[1],\n pre: str.slice(0, r[0]),\n body: str.slice(r[0] + a.length, r[1]),\n post: str.slice(r[1] + b.length)\n };\n}\n\nfunction maybeMatch(reg, str) {\n var m = str.match(reg);\n return m ? m[0] : null;\n}\n\nbalanced.range = range;\nfunction range(a, b, str) {\n var begs, beg, left, right, result;\n var ai = str.indexOf(a);\n var bi = str.indexOf(b, ai + 1);\n var i = ai;\n\n if (ai >= 0 && bi > 0) {\n begs = [];\n left = str.length;\n\n while (i >= 0 && !result) {\n if (i == ai) {\n begs.push(i);\n ai = str.indexOf(a, i + 1);\n } else if (begs.length == 1) {\n result = [ begs.pop(), bi ];\n } else {\n beg = begs.pop();\n if (beg < left) {\n left = beg;\n right = bi;\n }\n\n bi = str.indexOf(b, i + 1);\n }\n\n i = ai < bi && ai >= 0 ? ai : bi;\n }\n\n if (begs.length) {\n result = [ left, right ];\n }\n }\n\n return result;\n}\n","var concatMap = require('concat-map');\nvar balanced = require('balanced-match');\n\nmodule.exports = expandTop;\n\nvar escSlash = '\\0SLASH'+Math.random()+'\\0';\nvar escOpen = '\\0OPEN'+Math.random()+'\\0';\nvar escClose = '\\0CLOSE'+Math.random()+'\\0';\nvar escComma = '\\0COMMA'+Math.random()+'\\0';\nvar escPeriod = '\\0PERIOD'+Math.random()+'\\0';\n\nfunction numeric(str) {\n return parseInt(str, 10) == str\n ? parseInt(str, 10)\n : str.charCodeAt(0);\n}\n\nfunction escapeBraces(str) {\n return str.split('\\\\\\\\').join(escSlash)\n .split('\\\\{').join(escOpen)\n .split('\\\\}').join(escClose)\n .split('\\\\,').join(escComma)\n .split('\\\\.').join(escPeriod);\n}\n\nfunction unescapeBraces(str) {\n return str.split(escSlash).join('\\\\')\n .split(escOpen).join('{')\n .split(escClose).join('}')\n .split(escComma).join(',')\n .split(escPeriod).join('.');\n}\n\n\n// Basically just str.split(\",\"), but handling cases\n// where we have nested braced sections, which should be\n// treated as individual members, like {a,{b,c},d}\nfunction parseCommaParts(str) {\n if (!str)\n return [''];\n\n var parts = [];\n var m = balanced('{', '}', str);\n\n if (!m)\n return str.split(',');\n\n var pre = m.pre;\n var body = m.body;\n var post = m.post;\n var p = pre.split(',');\n\n p[p.length-1] += '{' + body + '}';\n var postParts = parseCommaParts(post);\n if (post.length) {\n p[p.length-1] += postParts.shift();\n p.push.apply(p, postParts);\n }\n\n parts.push.apply(parts, p);\n\n return parts;\n}\n\nfunction expandTop(str) {\n if (!str)\n return [];\n\n // I don't know why Bash 4.3 does this, but it does.\n // Anything starting with {} will have the first two bytes preserved\n // but *only* at the top level, so {},a}b will not expand to anything,\n // but a{},b}c will be expanded to [a}c,abc].\n // One could argue that this is a bug in Bash, but since the goal of\n // this module is to match Bash's rules, we escape a leading {}\n if (str.substr(0, 2) === '{}') {\n str = '\\\\{\\\\}' + str.substr(2);\n }\n\n return expand(escapeBraces(str), true).map(unescapeBraces);\n}\n\nfunction identity(e) {\n return e;\n}\n\nfunction embrace(str) {\n return '{' + str + '}';\n}\nfunction isPadded(el) {\n return /^-?0\\d/.test(el);\n}\n\nfunction lte(i, y) {\n return i <= y;\n}\nfunction gte(i, y) {\n return i >= y;\n}\n\nfunction expand(str, isTop) {\n var expansions = [];\n\n var m = balanced('{', '}', str);\n if (!m || /\\$$/.test(m.pre)) return [str];\n\n var isNumericSequence = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(m.body);\n var isAlphaSequence = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(m.body);\n var isSequence = isNumericSequence || isAlphaSequence;\n var isOptions = m.body.indexOf(',') >= 0;\n if (!isSequence && !isOptions) {\n // {a},b}\n if (m.post.match(/,.*\\}/)) {\n str = m.pre + '{' + m.body + escClose + m.post;\n return expand(str);\n }\n return [str];\n }\n\n var n;\n if (isSequence) {\n n = m.body.split(/\\.\\./);\n } else {\n n = parseCommaParts(m.body);\n if (n.length === 1) {\n // x{{a,b}}y ==> x{a}y x{b}y\n n = expand(n[0], false).map(embrace);\n if (n.length === 1) {\n var post = m.post.length\n ? expand(m.post, false)\n : [''];\n return post.map(function(p) {\n return m.pre + n[0] + p;\n });\n }\n }\n }\n\n // at this point, n is the parts, and we know it's not a comma set\n // with a single entry.\n\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n var pre = m.pre;\n var post = m.post.length\n ? expand(m.post, false)\n : [''];\n\n var N;\n\n if (isSequence) {\n var x = numeric(n[0]);\n var y = numeric(n[1]);\n var width = Math.max(n[0].length, n[1].length)\n var incr = n.length == 3\n ? Math.abs(numeric(n[2]))\n : 1;\n var test = lte;\n var reverse = y < x;\n if (reverse) {\n incr *= -1;\n test = gte;\n }\n var pad = n.some(isPadded);\n\n N = [];\n\n for (var i = x; test(i, y); i += incr) {\n var c;\n if (isAlphaSequence) {\n c = String.fromCharCode(i);\n if (c === '\\\\')\n c = '';\n } else {\n c = String(i);\n if (pad) {\n var need = width - c.length;\n if (need > 0) {\n var z = new Array(need + 1).join('0');\n if (i < 0)\n c = '-' + z + c.slice(1);\n else\n c = z + c;\n }\n }\n }\n N.push(c);\n }\n } else {\n N = concatMap(n, function(el) { return expand(el, false) });\n }\n\n for (var j = 0; j < N.length; j++) {\n for (var k = 0; k < post.length; k++) {\n var expansion = pre + N[j] + post[k];\n if (!isTop || isSequence || expansion)\n expansions.push(expansion);\n }\n }\n\n return expansions;\n}\n\n","module.exports = minimatch\nminimatch.Minimatch = Minimatch\n\nvar path = { sep: '/' }\ntry {\n path = require('path')\n} catch (er) {}\n\nvar GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}\nvar expand = require('brace-expansion')\n\nvar plTypes = {\n '!': { open: '(?:(?!(?:', close: '))[^/]*?)'},\n '?': { open: '(?:', close: ')?' },\n '+': { open: '(?:', close: ')+' },\n '*': { open: '(?:', close: ')*' },\n '@': { open: '(?:', close: ')' }\n}\n\n// any single thing other than /\n// don't need to escape / when using new RegExp()\nvar qmark = '[^/]'\n\n// * => any number of characters\nvar star = qmark + '*?'\n\n// ** when dots are allowed. Anything goes, except .. and .\n// not (^ or / followed by one or two dots followed by $ or /),\n// followed by anything, any number of times.\nvar twoStarDot = '(?:(?!(?:\\\\\\/|^)(?:\\\\.{1,2})($|\\\\\\/)).)*?'\n\n// not a ^ or / followed by a dot,\n// followed by anything, any number of times.\nvar twoStarNoDot = '(?:(?!(?:\\\\\\/|^)\\\\.).)*?'\n\n// characters that need to be escaped in RegExp.\nvar reSpecials = charSet('().*{}+?[]^$\\\\!')\n\n// \"abc\" -> { a:true, b:true, c:true }\nfunction charSet (s) {\n return s.split('').reduce(function (set, c) {\n set[c] = true\n return set\n }, {})\n}\n\n// normalizes slashes.\nvar slashSplit = /\\/+/\n\nminimatch.filter = filter\nfunction filter (pattern, options) {\n options = options || {}\n return function (p, i, list) {\n return minimatch(p, pattern, options)\n }\n}\n\nfunction ext (a, b) {\n a = a || {}\n b = b || {}\n var t = {}\n Object.keys(b).forEach(function (k) {\n t[k] = b[k]\n })\n Object.keys(a).forEach(function (k) {\n t[k] = a[k]\n })\n return t\n}\n\nminimatch.defaults = function (def) {\n if (!def || !Object.keys(def).length) return minimatch\n\n var orig = minimatch\n\n var m = function minimatch (p, pattern, options) {\n return orig.minimatch(p, pattern, ext(def, options))\n }\n\n m.Minimatch = function Minimatch (pattern, options) {\n return new orig.Minimatch(pattern, ext(def, options))\n }\n\n return m\n}\n\nMinimatch.defaults = function (def) {\n if (!def || !Object.keys(def).length) return Minimatch\n return minimatch.defaults(def).Minimatch\n}\n\nfunction minimatch (p, pattern, options) {\n if (typeof pattern !== 'string') {\n throw new TypeError('glob pattern string required')\n }\n\n if (!options) options = {}\n\n // shortcut: comments match nothing.\n if (!options.nocomment && pattern.charAt(0) === '#') {\n return false\n }\n\n // \"\" only matches \"\"\n if (pattern.trim() === '') return p === ''\n\n return new Minimatch(pattern, options).match(p)\n}\n\nfunction Minimatch (pattern, options) {\n if (!(this instanceof Minimatch)) {\n return new Minimatch(pattern, options)\n }\n\n if (typeof pattern !== 'string') {\n throw new TypeError('glob pattern string required')\n }\n\n if (!options) options = {}\n pattern = pattern.trim()\n\n // windows support: need to use /, not \\\n if (path.sep !== '/') {\n pattern = pattern.split(path.sep).join('/')\n }\n\n this.options = options\n this.set = []\n this.pattern = pattern\n this.regexp = null\n this.negate = false\n this.comment = false\n this.empty = false\n\n // make the set of regexps etc.\n this.make()\n}\n\nMinimatch.prototype.debug = function () {}\n\nMinimatch.prototype.make = make\nfunction make () {\n // don't do it more than once.\n if (this._made) return\n\n var pattern = this.pattern\n var options = this.options\n\n // empty patterns and comments match nothing.\n if (!options.nocomment && pattern.charAt(0) === '#') {\n this.comment = true\n return\n }\n if (!pattern) {\n this.empty = true\n return\n }\n\n // step 1: figure out negation, etc.\n this.parseNegate()\n\n // step 2: expand braces\n var set = this.globSet = this.braceExpand()\n\n if (options.debug) this.debug = console.error\n\n this.debug(this.pattern, set)\n\n // step 3: now we have a set, so turn each one into a series of path-portion\n // matching patterns.\n // These will be regexps, except in the case of \"**\", which is\n // set to the GLOBSTAR object for globstar behavior,\n // and will not contain any / characters\n set = this.globParts = set.map(function (s) {\n return s.split(slashSplit)\n })\n\n this.debug(this.pattern, set)\n\n // glob --> regexps\n set = set.map(function (s, si, set) {\n return s.map(this.parse, this)\n }, this)\n\n this.debug(this.pattern, set)\n\n // filter out everything that didn't compile properly.\n set = set.filter(function (s) {\n return s.indexOf(false) === -1\n })\n\n this.debug(this.pattern, set)\n\n this.set = set\n}\n\nMinimatch.prototype.parseNegate = parseNegate\nfunction parseNegate () {\n var pattern = this.pattern\n var negate = false\n var options = this.options\n var negateOffset = 0\n\n if (options.nonegate) return\n\n for (var i = 0, l = pattern.length\n ; i < l && pattern.charAt(i) === '!'\n ; i++) {\n negate = !negate\n negateOffset++\n }\n\n if (negateOffset) this.pattern = pattern.substr(negateOffset)\n this.negate = negate\n}\n\n// Brace expansion:\n// a{b,c}d -> abd acd\n// a{b,}c -> abc ac\n// a{0..3}d -> a0d a1d a2d a3d\n// a{b,c{d,e}f}g -> abg acdfg acefg\n// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg\n//\n// Invalid sets are not expanded.\n// a{2..}b -> a{2..}b\n// a{b}c -> a{b}c\nminimatch.braceExpand = function (pattern, options) {\n return braceExpand(pattern, options)\n}\n\nMinimatch.prototype.braceExpand = braceExpand\n\nfunction braceExpand (pattern, options) {\n if (!options) {\n if (this instanceof Minimatch) {\n options = this.options\n } else {\n options = {}\n }\n }\n\n pattern = typeof pattern === 'undefined'\n ? this.pattern : pattern\n\n if (typeof pattern === 'undefined') {\n throw new TypeError('undefined pattern')\n }\n\n if (options.nobrace ||\n !pattern.match(/\\{.*\\}/)) {\n // shortcut. no need to expand.\n return [pattern]\n }\n\n return expand(pattern)\n}\n\n// parse a component of the expanded set.\n// At this point, no pattern may contain \"/\" in it\n// so we're going to return a 2d array, where each entry is the full\n// pattern, split on '/', and then turned into a regular expression.\n// A regexp is made at the end which joins each array with an\n// escaped /, and another full one which joins each regexp with |.\n//\n// Following the lead of Bash 4.1, note that \"**\" only has special meaning\n// when it is the *only* thing in a path portion. Otherwise, any series\n// of * is equivalent to a single *. Globstar behavior is enabled by\n// default, and can be disabled by setting options.noglobstar.\nMinimatch.prototype.parse = parse\nvar SUBPARSE = {}\nfunction parse (pattern, isSub) {\n if (pattern.length > 1024 * 64) {\n throw new TypeError('pattern is too long')\n }\n\n var options = this.options\n\n // shortcuts\n if (!options.noglobstar && pattern === '**') return GLOBSTAR\n if (pattern === '') return ''\n\n var re = ''\n var hasMagic = !!options.nocase\n var escaping = false\n // ? => one single character\n var patternListStack = []\n var negativeLists = []\n var stateChar\n var inClass = false\n var reClassStart = -1\n var classStart = -1\n // . and .. never match anything that doesn't start with .,\n // even when options.dot is set.\n var patternStart = pattern.charAt(0) === '.' ? '' // anything\n // not (start or / followed by . or .. followed by / or end)\n : options.dot ? '(?!(?:^|\\\\\\/)\\\\.{1,2}(?:$|\\\\\\/))'\n : '(?!\\\\.)'\n var self = this\n\n function clearStateChar () {\n if (stateChar) {\n // we had some state-tracking character\n // that wasn't consumed by this pass.\n switch (stateChar) {\n case '*':\n re += star\n hasMagic = true\n break\n case '?':\n re += qmark\n hasMagic = true\n break\n default:\n re += '\\\\' + stateChar\n break\n }\n self.debug('clearStateChar %j %j', stateChar, re)\n stateChar = false\n }\n }\n\n for (var i = 0, len = pattern.length, c\n ; (i < len) && (c = pattern.charAt(i))\n ; i++) {\n this.debug('%s\\t%s %s %j', pattern, i, re, c)\n\n // skip over any that are escaped.\n if (escaping && reSpecials[c]) {\n re += '\\\\' + c\n escaping = false\n continue\n }\n\n switch (c) {\n case '/':\n // completely not allowed, even escaped.\n // Should already be path-split by now.\n return false\n\n case '\\\\':\n clearStateChar()\n escaping = true\n continue\n\n // the various stateChar values\n // for the \"extglob\" stuff.\n case '?':\n case '*':\n case '+':\n case '@':\n case '!':\n this.debug('%s\\t%s %s %j <-- stateChar', pattern, i, re, c)\n\n // all of those are literals inside a class, except that\n // the glob [!a] means [^a] in regexp\n if (inClass) {\n this.debug(' in class')\n if (c === '!' && i === classStart + 1) c = '^'\n re += c\n continue\n }\n\n // if we already have a stateChar, then it means\n // that there was something like ** or +? in there.\n // Handle the stateChar, then proceed with this one.\n self.debug('call clearStateChar %j', stateChar)\n clearStateChar()\n stateChar = c\n // if extglob is disabled, then +(asdf|foo) isn't a thing.\n // just clear the statechar *now*, rather than even diving into\n // the patternList stuff.\n if (options.noext) clearStateChar()\n continue\n\n case '(':\n if (inClass) {\n re += '('\n continue\n }\n\n if (!stateChar) {\n re += '\\\\('\n continue\n }\n\n patternListStack.push({\n type: stateChar,\n start: i - 1,\n reStart: re.length,\n open: plTypes[stateChar].open,\n close: plTypes[stateChar].close\n })\n // negation is (?:(?!js)[^/]*)\n re += stateChar === '!' ? '(?:(?!(?:' : '(?:'\n this.debug('plType %j %j', stateChar, re)\n stateChar = false\n continue\n\n case ')':\n if (inClass || !patternListStack.length) {\n re += '\\\\)'\n continue\n }\n\n clearStateChar()\n hasMagic = true\n var pl = patternListStack.pop()\n // negation is (?:(?!js)[^/]*)\n // The others are (?:<pattern>)<type>\n re += pl.close\n if (pl.type === '!') {\n negativeLists.push(pl)\n }\n pl.reEnd = re.length\n continue\n\n case '|':\n if (inClass || !patternListStack.length || escaping) {\n re += '\\\\|'\n escaping = false\n continue\n }\n\n clearStateChar()\n re += '|'\n continue\n\n // these are mostly the same in regexp and glob\n case '[':\n // swallow any state-tracking char before the [\n clearStateChar()\n\n if (inClass) {\n re += '\\\\' + c\n continue\n }\n\n inClass = true\n classStart = i\n reClassStart = re.length\n re += c\n continue\n\n case ']':\n // a right bracket shall lose its special\n // meaning and represent itself in\n // a bracket expression if it occurs\n // first in the list. -- POSIX.2 2.8.3.2\n if (i === classStart + 1 || !inClass) {\n re += '\\\\' + c\n escaping = false\n continue\n }\n\n // handle the case where we left a class open.\n // \"[z-a]\" is valid, equivalent to \"\\[z-a\\]\"\n if (inClass) {\n // split where the last [ was, make sure we don't have\n // an invalid re. if so, re-walk the contents of the\n // would-be class to re-translate any characters that\n // were passed through as-is\n // TODO: It would probably be faster to determine this\n // without a try/catch and a new RegExp, but it's tricky\n // to do safely. For now, this is safe and works.\n var cs = pattern.substring(classStart + 1, i)\n try {\n RegExp('[' + cs + ']')\n } catch (er) {\n // not a valid class!\n var sp = this.parse(cs, SUBPARSE)\n re = re.substr(0, reClassStart) + '\\\\[' + sp[0] + '\\\\]'\n hasMagic = hasMagic || sp[1]\n inClass = false\n continue\n }\n }\n\n // finish up the class.\n hasMagic = true\n inClass = false\n re += c\n continue\n\n default:\n // swallow any state char that wasn't consumed\n clearStateChar()\n\n if (escaping) {\n // no need\n escaping = false\n } else if (reSpecials[c]\n && !(c === '^' && inClass)) {\n re += '\\\\'\n }\n\n re += c\n\n } // switch\n } // for\n\n // handle the case where we left a class open.\n // \"[abc\" is valid, equivalent to \"\\[abc\"\n if (inClass) {\n // split where the last [ was, and escape it\n // this is a huge pita. We now have to re-walk\n // the contents of the would-be class to re-translate\n // any characters that were passed through as-is\n cs = pattern.substr(classStart + 1)\n sp = this.parse(cs, SUBPARSE)\n re = re.substr(0, reClassStart) + '\\\\[' + sp[0]\n hasMagic = hasMagic || sp[1]\n }\n\n // handle the case where we had a +( thing at the *end*\n // of the pattern.\n // each pattern list stack adds 3 chars, and we need to go through\n // and escape any | chars that were passed through as-is for the regexp.\n // Go through and escape them, taking care not to double-escape any\n // | chars that were already escaped.\n for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {\n var tail = re.slice(pl.reStart + pl.open.length)\n this.debug('setting tail', re, pl)\n // maybe some even number of \\, then maybe 1 \\, followed by a |\n tail = tail.replace(/((?:\\\\{2}){0,64})(\\\\?)\\|/g, function (_, $1, $2) {\n if (!$2) {\n // the | isn't already escaped, so escape it.\n $2 = '\\\\'\n }\n\n // need to escape all those slashes *again*, without escaping the\n // one that we need for escaping the | character. As it works out,\n // escaping an even number of slashes can be done by simply repeating\n // it exactly after itself. That's why this trick works.\n //\n // I am sorry that you have to see this.\n return $1 + $1 + $2 + '|'\n })\n\n this.debug('tail=%j\\n %s', tail, tail, pl, re)\n var t = pl.type === '*' ? star\n : pl.type === '?' ? qmark\n : '\\\\' + pl.type\n\n hasMagic = true\n re = re.slice(0, pl.reStart) + t + '\\\\(' + tail\n }\n\n // handle trailing things that only matter at the very end.\n clearStateChar()\n if (escaping) {\n // trailing \\\\\n re += '\\\\\\\\'\n }\n\n // only need to apply the nodot start if the re starts with\n // something that could conceivably capture a dot\n var addPatternStart = false\n switch (re.charAt(0)) {\n case '.':\n case '[':\n case '(': addPatternStart = true\n }\n\n // Hack to work around lack of negative lookbehind in JS\n // A pattern like: *.!(x).!(y|z) needs to ensure that a name\n // like 'a.xyz.yz' doesn't match. So, the first negative\n // lookahead, has to look ALL the way ahead, to the end of\n // the pattern.\n for (var n = negativeLists.length - 1; n > -1; n--) {\n var nl = negativeLists[n]\n\n var nlBefore = re.slice(0, nl.reStart)\n var nlFirst = re.slice(nl.reStart, nl.reEnd - 8)\n var nlLast = re.slice(nl.reEnd - 8, nl.reEnd)\n var nlAfter = re.slice(nl.reEnd)\n\n nlLast += nlAfter\n\n // Handle nested stuff like *(*.js|!(*.json)), where open parens\n // mean that we should *not* include the ) in the bit that is considered\n // \"after\" the negated section.\n var openParensBefore = nlBefore.split('(').length - 1\n var cleanAfter = nlAfter\n for (i = 0; i < openParensBefore; i++) {\n cleanAfter = cleanAfter.replace(/\\)[+*?]?/, '')\n }\n nlAfter = cleanAfter\n\n var dollar = ''\n if (nlAfter === '' && isSub !== SUBPARSE) {\n dollar = '$'\n }\n var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast\n re = newRe\n }\n\n // if the re is not \"\" at this point, then we need to make sure\n // it doesn't match against an empty path part.\n // Otherwise a/* will match a/, which it should not.\n if (re !== '' && hasMagic) {\n re = '(?=.)' + re\n }\n\n if (addPatternStart) {\n re = patternStart + re\n }\n\n // parsing just a piece of a larger pattern.\n if (isSub === SUBPARSE) {\n return [re, hasMagic]\n }\n\n // skip the regexp for non-magical patterns\n // unescape anything in it, though, so that it'll be\n // an exact match against a file etc.\n if (!hasMagic) {\n return globUnescape(pattern)\n }\n\n var flags = options.nocase ? 'i' : ''\n try {\n var regExp = new RegExp('^' + re + '$', flags)\n } catch (er) {\n // If it was an invalid regular expression, then it can't match\n // anything. This trick looks for a character after the end of\n // the string, which is of course impossible, except in multi-line\n // mode, but it's not a /m regex.\n return new RegExp('$.')\n }\n\n regExp._glob = pattern\n regExp._src = re\n\n return regExp\n}\n\nminimatch.makeRe = function (pattern, options) {\n return new Minimatch(pattern, options || {}).makeRe()\n}\n\nMinimatch.prototype.makeRe = makeRe\nfunction makeRe () {\n if (this.regexp || this.regexp === false) return this.regexp\n\n // at this point, this.set is a 2d array of partial\n // pattern strings, or \"**\".\n //\n // It's better to use .match(). This function shouldn't\n // be used, really, but it's pretty convenient sometimes,\n // when you just want to work with a regex.\n var set = this.set\n\n if (!set.length) {\n this.regexp = false\n return this.regexp\n }\n var options = this.options\n\n var twoStar = options.noglobstar ? star\n : options.dot ? twoStarDot\n : twoStarNoDot\n var flags = options.nocase ? 'i' : ''\n\n var re = set.map(function (pattern) {\n return pattern.map(function (p) {\n return (p === GLOBSTAR) ? twoStar\n : (typeof p === 'string') ? regExpEscape(p)\n : p._src\n }).join('\\\\\\/')\n }).join('|')\n\n // must match entire pattern\n // ending in a * or ** will make it less strict.\n re = '^(?:' + re + ')$'\n\n // can match anything, as long as it's not this.\n if (this.negate) re = '^(?!' + re + ').*$'\n\n try {\n this.regexp = new RegExp(re, flags)\n } catch (ex) {\n this.regexp = false\n }\n return this.regexp\n}\n\nminimatch.match = function (list, pattern, options) {\n options = options || {}\n var mm = new Minimatch(pattern, options)\n list = list.filter(function (f) {\n return mm.match(f)\n })\n if (mm.options.nonull && !list.length) {\n list.push(pattern)\n }\n return list\n}\n\nMinimatch.prototype.match = match\nfunction match (f, partial) {\n this.debug('match', f, this.pattern)\n // short-circuit in the case of busted things.\n // comments, etc.\n if (this.comment) return false\n if (this.empty) return f === ''\n\n if (f === '/' && partial) return true\n\n var options = this.options\n\n // windows: need to use /, not \\\n if (path.sep !== '/') {\n f = f.split(path.sep).join('/')\n }\n\n // treat the test path as a set of pathparts.\n f = f.split(slashSplit)\n this.debug(this.pattern, 'split', f)\n\n // just ONE of the pattern sets in this.set needs to match\n // in order for it to be valid. If negating, then just one\n // match means that we have failed.\n // Either way, return on the first hit.\n\n var set = this.set\n this.debug(this.pattern, 'set', set)\n\n // Find the basename of the path by looking for the last non-empty segment\n var filename\n var i\n for (i = f.length - 1; i >= 0; i--) {\n filename = f[i]\n if (filename) break\n }\n\n for (i = 0; i < set.length; i++) {\n var pattern = set[i]\n var file = f\n if (options.matchBase && pattern.length === 1) {\n file = [filename]\n }\n var hit = this.matchOne(file, pattern, partial)\n if (hit) {\n if (options.flipNegate) return true\n return !this.negate\n }\n }\n\n // didn't get any hits. this is success if it's a negative\n // pattern, failure otherwise.\n if (options.flipNegate) return false\n return this.negate\n}\n\n// set partial to true to test if, for example,\n// \"/a/b\" matches the start of \"/*/b/*/d\"\n// Partial means, if you run out of file before you run\n// out of pattern, then that's fine, as long as all\n// the parts match.\nMinimatch.prototype.matchOne = function (file, pattern, partial) {\n var options = this.options\n\n this.debug('matchOne',\n { 'this': this, file: file, pattern: pattern })\n\n this.debug('matchOne', file.length, pattern.length)\n\n for (var fi = 0,\n pi = 0,\n fl = file.length,\n pl = pattern.length\n ; (fi < fl) && (pi < pl)\n ; fi++, pi++) {\n this.debug('matchOne loop')\n var p = pattern[pi]\n var f = file[fi]\n\n this.debug(pattern, p, f)\n\n // should be impossible.\n // some invalid regexp stuff in the set.\n if (p === false) return false\n\n if (p === GLOBSTAR) {\n this.debug('GLOBSTAR', [pattern, p, f])\n\n // \"**\"\n // a/**/b/**/c would match the following:\n // a/b/x/y/z/c\n // a/x/y/z/b/c\n // a/b/x/b/x/c\n // a/b/c\n // To do this, take the rest of the pattern after\n // the **, and see if it would match the file remainder.\n // If so, return success.\n // If not, the ** \"swallows\" a segment, and try again.\n // This is recursively awful.\n //\n // a/**/b/**/c matching a/b/x/y/z/c\n // - a matches a\n // - doublestar\n // - matchOne(b/x/y/z/c, b/**/c)\n // - b matches b\n // - doublestar\n // - matchOne(x/y/z/c, c) -> no\n // - matchOne(y/z/c, c) -> no\n // - matchOne(z/c, c) -> no\n // - matchOne(c, c) yes, hit\n var fr = fi\n var pr = pi + 1\n if (pr === pl) {\n this.debug('** at the end')\n // a ** at the end will just swallow the rest.\n // We have found a match.\n // however, it will not swallow /.x, unless\n // options.dot is set.\n // . and .. are *never* matched by **, for explosively\n // exponential reasons.\n for (; fi < fl; fi++) {\n if (file[fi] === '.' || file[fi] === '..' ||\n (!options.dot && file[fi].charAt(0) === '.')) return false\n }\n return true\n }\n\n // ok, let's see if we can swallow whatever we can.\n while (fr < fl) {\n var swallowee = file[fr]\n\n this.debug('\\nglobstar while', file, fr, pattern, pr, swallowee)\n\n // XXX remove this slice. Just pass the start index.\n if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {\n this.debug('globstar found match!', fr, fl, swallowee)\n // found a match.\n return true\n } else {\n // can't swallow \".\" or \"..\" ever.\n // can only swallow \".foo\" when explicitly asked.\n if (swallowee === '.' || swallowee === '..' ||\n (!options.dot && swallowee.charAt(0) === '.')) {\n this.debug('dot detected!', file, fr, pattern, pr)\n break\n }\n\n // ** swallows a segment, and continue.\n this.debug('globstar swallow a segment, and continue')\n fr++\n }\n }\n\n // no match was found.\n // However, in partial mode, we can't say this is necessarily over.\n // If there's more *pattern* left, then\n if (partial) {\n // ran out of file\n this.debug('\\n>>> no match, partial?', file, fr, pattern, pr)\n if (fr === fl) return true\n }\n return false\n }\n\n // something other than **\n // non-magic patterns just have to match exactly\n // patterns with magic have been turned into regexps.\n var hit\n if (typeof p === 'string') {\n if (options.nocase) {\n hit = f.toLowerCase() === p.toLowerCase()\n } else {\n hit = f === p\n }\n this.debug('string match', p, f, hit)\n } else {\n hit = f.match(p)\n this.debug('pattern match', p, f, hit)\n }\n\n if (!hit) return false\n }\n\n // Note: ending in / means that we'll get a final \"\"\n // at the end of the pattern. This can only match a\n // corresponding \"\" at the end of the file.\n // If the file ends in /, then it can only match a\n // a pattern that ends in /, unless the pattern just\n // doesn't have any more for it. But, a/b/ should *not*\n // match \"a/b/*\", even though \"\" matches against the\n // [^/]*? pattern, except in partial mode, where it might\n // simply not be reached yet.\n // However, a/b/ should still satisfy a/*\n\n // now either we fell off the end of the pattern, or we're done.\n if (fi === fl && pi === pl) {\n // ran out of pattern and filename at the same time.\n // an exact hit!\n return true\n } else if (fi === fl) {\n // ran out of file, but still had pattern left.\n // this is ok if we're doing the match as part of\n // a glob fs traversal.\n return partial\n } else if (pi === pl) {\n // ran out of pattern, still have file left.\n // this is only acceptable if we're on the very last\n // empty segment of a file with a trailing slash.\n // a/* should match a/b/\n var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')\n return emptyFileEnd\n }\n\n // should be unreachable.\n throw new Error('wtf?')\n}\n\n// replace stuff like \\* with *\nfunction globUnescape (s) {\n return s.replace(/\\\\(.)/g, '$1')\n}\n\nfunction regExpEscape (s) {\n return s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&')\n}\n","var Path = require('../path.js');\nvar Errors = require('../errors.js');\nvar Environment = require('./environment.js');\nvar async = require('../../lib/async.js');\nvar Encoding = require('../encoding.js');\nvar minimatch = require('minimatch');\n\nfunction Shell(fs, options) {\n options = options || {};\n\n var env = new Environment(options.env);\n var cwd = '/';\n\n /**\n * The bound FileSystem (cannot be changed)\n */\n Object.defineProperty(this, 'fs', {\n get: function() { return fs; },\n enumerable: true\n });\n\n /**\n * The shell's environment (e.g., for things like\n * path, tmp, and other env vars). Use env.get()\n * and env.set() to work with variables.\n */\n Object.defineProperty(this, 'env', {\n get: function() { return env; },\n enumerable: true\n });\n\n /**\n * Change the current working directory. We\n * include `cd` on the `this` vs. proto so that\n * we can access cwd without exposing it externally.\n */\n this.cd = function(path, callback) {\n path = Path.resolve(cwd, path);\n // Make sure the path actually exists, and is a dir\n fs.stat(path, function(err, stats) {\n if(err) {\n callback(new Errors.ENOTDIR(null, path));\n return;\n }\n if(stats.type === 'DIRECTORY') {\n cwd = path;\n callback();\n } else {\n callback(new Errors.ENOTDIR(null, path));\n }\n });\n };\n\n /**\n * Get the current working directory (changed with `cd()`)\n */\n this.pwd = function() {\n return cwd;\n };\n}\n\n/**\n * Execute the .js command located at `path`. Such commands\n * should assume the existence of 3 arguments, which will be\n * defined at runtime:\n *\n * * fs - the current shell's bound filesystem object\n * * args - a list of arguments for the command, or an empty list if none\n * * callback - a callback function(error, result) to call when done.\n *\n * The .js command's contents should be the body of a function\n * that looks like this:\n *\n * function(fs, args, callback) {\n * // .js code here\n * }\n */\nShell.prototype.exec = function(path, args, callback) {\n /* jshint evil:true */\n var sh = this;\n var fs = sh.fs;\n if(typeof args === 'function') {\n callback = args;\n args = [];\n }\n args = args || [];\n callback = callback || function(){};\n path = Path.resolve(sh.pwd(), path);\n\n fs.readFile(path, \"utf8\", function(error, data) {\n if(error) {\n callback(error);\n return;\n }\n try {\n var cmd = new Function('fs', 'args', 'callback', data);\n cmd(fs, args, callback);\n } catch(e) {\n callback(e);\n }\n });\n};\n\n/**\n * Create a file if it does not exist, or update access and\n * modified times if it does. Valid options include:\n *\n * * updateOnly - whether to create the file if missing (defaults to false)\n * * date - use the provided Date value instead of current date/time\n */\nShell.prototype.touch = function(path, options, callback) {\n var sh = this;\n var fs = sh.fs;\n if(typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n callback = callback || function(){};\n path = Path.resolve(sh.pwd(), path);\n\n function createFile(path) {\n fs.writeFile(path, '', callback);\n }\n\n function updateTimes(path) {\n var now = Date.now();\n var atime = options.date || now;\n var mtime = options.date || now;\n\n fs.utimes(path, atime, mtime, callback);\n }\n\n fs.stat(path, function(error, stats) {\n if(error) {\n if(options.updateOnly === true) {\n callback();\n } else {\n createFile(path);\n }\n } else {\n updateTimes(path);\n }\n });\n};\n\n/**\n * Concatenate multiple files into a single String, with each\n * file separated by a newline. The `files` argument should\n * be a String (path to single file) or an Array of Strings\n * (multiple file paths).\n */\nShell.prototype.cat = function(files, callback) {\n var sh = this;\n var fs = sh.fs;\n var all = '';\n callback = callback || function(){};\n\n if(!files) {\n callback(new Errors.EINVAL('Missing files argument'));\n return;\n }\n\n files = typeof files === 'string' ? [ files ] : files;\n\n function append(item, callback) {\n var filename = Path.resolve(sh.pwd(), item);\n fs.readFile(filename, 'utf8', function(error, data) {\n if(error) {\n callback(error);\n return;\n }\n all += data + '\\n';\n callback();\n });\n }\n\n async.eachSeries(files, append, function(error) {\n if(error) {\n callback(error);\n } else {\n callback(null, all.replace(/\\n$/, ''));\n }\n });\n};\n\n/**\n * Get the listing of a directory, returning an array of\n * file entries in the following form:\n *\n * {\n * path: <String> the basename of the directory entry\n * links: <Number> the number of links to the entry\n * size: <Number> the size in bytes of the entry\n * modified: <Number> the last modified date/time\n * type: <String> the type of the entry\n * contents: <Array> an optional array of child entries\n * }\n *\n * By default ls() gives a shallow listing. If you want\n * to follow directories as they are encountered, use\n * the `recursive=true` option.\n */\nShell.prototype.ls = function(dir, options, callback) {\n var sh = this;\n var fs = sh.fs;\n if(typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n callback = callback || function(){};\n\n if(!dir) {\n callback(new Errors.EINVAL('Missing dir argument'));\n return;\n }\n\n function list(path, callback) {\n var pathname = Path.resolve(sh.pwd(), path);\n var result = [];\n\n fs.readdir(pathname, function(error, entries) {\n if(error) {\n callback(error);\n return;\n }\n\n function getDirEntry(name, callback) {\n name = Path.join(pathname, name);\n fs.stat(name, function(error, stats) {\n if(error) {\n callback(error);\n return;\n }\n var entry = {\n path: Path.basename(name),\n links: stats.nlinks,\n size: stats.size,\n modified: stats.mtime,\n type: stats.type\n };\n\n if(options.recursive && stats.type === 'DIRECTORY') {\n list(Path.join(pathname, entry.path), function(error, items) {\n if(error) {\n callback(error);\n return;\n }\n entry.contents = items;\n result.push(entry);\n callback();\n });\n } else {\n result.push(entry);\n callback();\n }\n });\n }\n\n async.eachSeries(entries, getDirEntry, function(error) {\n callback(error, result);\n });\n });\n }\n\n list(dir, callback);\n};\n\n/**\n * Removes the file or directory at `path`. If `path` is a file\n * it will be removed. If `path` is a directory, it will be\n * removed if it is empty, otherwise the callback will receive\n * an error. In order to remove non-empty directories, use the\n * `recursive=true` option.\n */\nShell.prototype.rm = function(path, options, callback) {\n var sh = this;\n var fs = sh.fs;\n if(typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n callback = callback || function(){};\n\n if(!path) {\n callback(new Errors.EINVAL('Missing path argument'));\n return;\n }\n\n function remove(pathname, callback) {\n pathname = Path.resolve(sh.pwd(), pathname);\n fs.stat(pathname, function(error, stats) {\n if(error) {\n callback(error);\n return;\n }\n\n // If this is a file, delete it and we're done\n if(stats.type === 'FILE') {\n fs.unlink(pathname, callback);\n return;\n }\n\n // If it's a dir, check if it's empty\n fs.readdir(pathname, function(error, entries) {\n if(error) {\n callback(error);\n return;\n }\n\n // If dir is empty, delete it and we're done\n if(entries.length === 0) {\n fs.rmdir(pathname, callback);\n return;\n }\n\n // If not, see if we're allowed to delete recursively\n if(!options.recursive) {\n callback(new Errors.ENOTEMPTY(null, pathname));\n return;\n }\n\n // Remove each dir entry recursively, then delete the dir.\n entries = entries.map(function(filename) {\n // Root dir entries absolutely\n return Path.join(pathname, filename);\n });\n async.eachSeries(entries, remove, function(error) {\n if(error) {\n callback(error);\n return;\n }\n fs.rmdir(pathname, callback);\n });\n });\n });\n }\n\n remove(path, callback);\n};\n\n/**\n * Gets the path to the temporary directory, creating it if not\n * present. The directory used is the one specified in\n * env.TMP. The callback receives (error, tempDirName).\n */\nShell.prototype.tempDir = function(callback) {\n var sh = this;\n var fs = sh.fs;\n var tmp = sh.env.get('TMP');\n callback = callback || function(){};\n\n // Try and create it, and it will either work or fail\n // but either way it's now there.\n fs.mkdir(tmp, function(err) {\n callback(null, tmp);\n });\n};\n\n/**\n * Recursively creates the directory at `path`. If the parent\n * of `path` does not exist, it will be created.\n * Based off EnsureDir by Sam X. Xu\n * https://www.npmjs.org/package/ensureDir\n * MIT License\n */\nShell.prototype.mkdirp = function(path, callback) {\n var sh = this;\n var fs = sh.fs;\n callback = callback || function(){};\n\n if(!path) {\n callback(new Errors.EINVAL('Missing path argument'));\n return;\n }\n else if (path === '/') {\n callback();\n return;\n }\n function _mkdirp(path, callback) {\n fs.stat(path, function (err, stat) {\n if(stat) {\n if(stat.isDirectory()) {\n callback();\n return;\n }\n else if (stat.isFile()) {\n callback(new Errors.ENOTDIR(null, path));\n return;\n }\n }\n else if (err && err.code !== 'ENOENT') {\n callback(err);\n return;\n }\n else {\n var parent = Path.dirname(path);\n if(parent === '/') {\n fs.mkdir(path, function (err) {\n if (err && err.code != 'EEXIST') {\n callback(err);\n return;\n }\n callback();\n return;\n });\n }\n else {\n _mkdirp(parent, function (err) {\n if (err) return callback(err);\n fs.mkdir(path, function (err) {\n if (err && err.code != 'EEXIST') {\n callback(err);\n return;\n }\n callback();\n return;\n });\n });\n }\n }\n });\n }\n\n _mkdirp(path, callback);\n};\n\n/**\n * Recursively walk a directory tree, reporting back all paths\n * that were found along the way. The `path` must be a dir.\n * Valid options include a `regex` for pattern matching paths\n * and an `exec` function of the form `function(path, next)` where\n * `path` is the current path that was found (dir paths have an '/'\n * appended) and `next` is a callback to call when done processing\n * the current path, passing any error object back as the first argument.\n * `find` returns a flat array of absolute paths for all matching/found\n * paths as the final argument to the callback.\n */\n Shell.prototype.find = function(path, options, callback) {\n var sh = this;\n var fs = sh.fs;\n if(typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n callback = callback || function(){};\n\n var exec = options.exec || function(path, next) { next(); };\n var found = [];\n\n if(!path) {\n callback(new Errors.EINVAL('Missing path argument'));\n return;\n }\n\n function processPath(path, callback) {\n exec(path, function(err) {\n if(err) {\n callback(err);\n return;\n }\n\n found.push(path);\n callback();\n });\n }\n\n function maybeProcessPath(path, callback) {\n // Test the path against the user's regex, name, path primaries (if any)\n // and remove any trailing slashes added previously.\n var rawPath = Path.removeTrailing(path);\n\n // Check entire path against provided regex, if any\n if(options.regex && !options.regex.test(rawPath)) {\n callback();\n return;\n }\n\n // Check basename for matches against name primary, if any\n if(options.name && !minimatch(Path.basename(rawPath), options.name)) {\n callback();\n return;\n }\n\n // Check dirname for matches against path primary, if any\n if(options.path && !minimatch(Path.dirname(rawPath), options.path)) {\n callback();\n return;\n }\n\n processPath(path, callback);\n }\n\n function walk(path, callback) {\n path = Path.resolve(sh.pwd(), path);\n\n // The path is either a file or dir, and instead of doing\n // a stat() to determine it first, we just try to readdir()\n // and it will either work or not, and we handle the non-dir error.\n fs.readdir(path, function(err, entries) {\n if(err) {\n if(err.code === 'ENOTDIR' /* file case, ignore error */) {\n maybeProcessPath(path, callback);\n } else {\n callback(err);\n }\n return;\n }\n\n // Path is really a dir, add a trailing / and report it found\n maybeProcessPath(Path.addTrailing(path), function(err) {\n if(err) {\n callback(err);\n return;\n }\n\n entries = entries.map(function(entry) {\n return Path.join(path, entry);\n });\n\n async.eachSeries(entries, walk, function(err) {\n callback(err, found);\n });\n });\n });\n }\n\n // Make sure we are starting with a dir path\n fs.stat(path, function(err, stats) {\n if(err) {\n callback(err);\n return;\n }\n if(!stats.isDirectory()) {\n callback(new Errors.ENOTDIR(null, path));\n return;\n }\n\n walk(path, callback);\n });\n};\n\nmodule.exports = Shell;\n","// Based on https://github.com/diy/intercom.js/blob/master/lib/events.js\n// Copyright 2012 DIY Co Apache License, Version 2.0\n// http://www.apache.org/licenses/LICENSE-2.0\n\nfunction removeItem(item, array) {\n for (var i = array.length - 1; i >= 0; i--) {\n if (array[i] === item) {\n array.splice(i, 1);\n }\n }\n return array;\n}\n\nvar EventEmitter = function() {};\n\nEventEmitter.createInterface = function(space) {\n var methods = {};\n\n methods.on = function(name, fn) {\n if (typeof this[space] === 'undefined') {\n this[space] = {};\n }\n if (!this[space].hasOwnProperty(name)) {\n this[space][name] = [];\n }\n this[space][name].push(fn);\n };\n\n methods.off = function(name, fn) {\n if (typeof this[space] === 'undefined') return;\n if (this[space].hasOwnProperty(name)) {\n removeItem(fn, this[space][name]);\n }\n };\n\n methods.trigger = function(name) {\n if (typeof this[space] !== 'undefined' && this[space].hasOwnProperty(name)) {\n var args = Array.prototype.slice.call(arguments, 1);\n for (var i = 0; i < this[space][name].length; i++) {\n this[space][name][i].apply(this[space][name][i], args);\n }\n }\n };\n\n methods.removeAllListeners = function(name) {\n if (typeof this[space] === 'undefined') return;\n var self = this;\n self[space][name].forEach(function(fn) {\n self.off(name, fn);\n });\n };\n\n return methods;\n};\n\nvar pvt = EventEmitter.createInterface('_handlers');\nEventEmitter.prototype._on = pvt.on;\nEventEmitter.prototype._off = pvt.off;\nEventEmitter.prototype._trigger = pvt.trigger;\n\nvar pub = EventEmitter.createInterface('handlers');\nEventEmitter.prototype.on = function() {\n pub.on.apply(this, arguments);\n Array.prototype.unshift.call(arguments, 'on');\n this._trigger.apply(this, arguments);\n};\nEventEmitter.prototype.off = pub.off;\nEventEmitter.prototype.trigger = pub.trigger;\nEventEmitter.prototype.removeAllListeners = pub.removeAllListeners;\n\nmodule.exports = EventEmitter;\n","// Based on https://github.com/diy/intercom.js/blob/master/lib/intercom.js\n// Copyright 2012 DIY Co Apache License, Version 2.0\n// http://www.apache.org/licenses/LICENSE-2.0\n\nvar EventEmitter = require('./eventemitter.js');\nvar guid = require('../src/shared.js').guid;\n\nfunction throttle(delay, fn) {\n var last = 0;\n return function() {\n var now = Date.now();\n if (now - last > delay) {\n last = now;\n fn.apply(this, arguments);\n }\n };\n}\n\nfunction extend(a, b) {\n if (typeof a === 'undefined' || !a) { a = {}; }\n if (typeof b === 'object') {\n for (var key in b) {\n if (b.hasOwnProperty(key)) {\n a[key] = b[key];\n }\n }\n }\n return a;\n}\n\nvar localStorage = (function(window) {\n if (typeof window === 'undefined' ||\n typeof window.localStorage === 'undefined') {\n return {\n getItem : function() {},\n setItem : function() {},\n removeItem : function() {}\n };\n }\n return window.localStorage;\n}(global));\n\nfunction Intercom() {\n var self = this;\n var now = Date.now();\n\n this.origin = guid();\n this.lastMessage = now;\n this.receivedIDs = {};\n this.previousValues = {};\n\n var storageHandler = function() {\n self._onStorageEvent.apply(self, arguments);\n };\n\n // If we're in node.js, skip event registration\n if (typeof document === 'undefined') {\n return;\n }\n\n if (document.attachEvent) {\n document.attachEvent('onstorage', storageHandler);\n } else {\n global.addEventListener('storage', storageHandler, false);\n }\n}\n\nIntercom.prototype._transaction = function(fn) {\n var TIMEOUT = 1000;\n var WAIT = 20;\n var self = this;\n var executed = false;\n var listening = false;\n var waitTimer = null;\n\n function lock() {\n if (executed) {\n return;\n }\n\n var now = Date.now();\n var activeLock = localStorage.getItem(INDEX_LOCK)|0;\n if (activeLock && now - activeLock < TIMEOUT) {\n if (!listening) {\n self._on('storage', lock);\n listening = true;\n }\n waitTimer = setTimeout(lock, WAIT);\n return;\n }\n executed = true;\n localStorage.setItem(INDEX_LOCK, now);\n\n fn();\n unlock();\n }\n\n function unlock() {\n if (listening) {\n self._off('storage', lock);\n }\n if (waitTimer) {\n clearTimeout(waitTimer);\n }\n localStorage.removeItem(INDEX_LOCK);\n }\n\n lock();\n};\n\nIntercom.prototype._cleanup_emit = throttle(100, function() {\n var self = this;\n\n self._transaction(function() {\n var now = Date.now();\n var threshold = now - THRESHOLD_TTL_EMIT;\n var changed = 0;\n var messages;\n\n try {\n messages = JSON.parse(localStorage.getItem(INDEX_EMIT) || '[]');\n } catch(e) {\n messages = [];\n }\n for (var i = messages.length - 1; i >= 0; i--) {\n if (messages[i].timestamp < threshold) {\n messages.splice(i, 1);\n changed++;\n }\n }\n if (changed > 0) {\n localStorage.setItem(INDEX_EMIT, JSON.stringify(messages));\n }\n });\n});\n\nIntercom.prototype._cleanup_once = throttle(100, function() {\n var self = this;\n\n self._transaction(function() {\n var timestamp, ttl, key;\n var table;\n var now = Date.now();\n var changed = 0;\n\n try {\n table = JSON.parse(localStorage.getItem(INDEX_ONCE) || '{}');\n } catch(e) {\n table = {};\n }\n for (key in table) {\n if (self._once_expired(key, table)) {\n delete table[key];\n changed++;\n }\n }\n\n if (changed > 0) {\n localStorage.setItem(INDEX_ONCE, JSON.stringify(table));\n }\n });\n});\n\nIntercom.prototype._once_expired = function(key, table) {\n if (!table) {\n return true;\n }\n if (!table.hasOwnProperty(key)) {\n return true;\n }\n if (typeof table[key] !== 'object') {\n return true;\n }\n\n var ttl = table[key].ttl || THRESHOLD_TTL_ONCE;\n var now = Date.now();\n var timestamp = table[key].timestamp;\n return timestamp < now - ttl;\n};\n\nIntercom.prototype._localStorageChanged = function(event, field) {\n if (event && event.key) {\n return event.key === field;\n }\n\n var currentValue = localStorage.getItem(field);\n if (currentValue === this.previousValues[field]) {\n return false;\n }\n this.previousValues[field] = currentValue;\n return true;\n};\n\nIntercom.prototype._onStorageEvent = function(event) {\n event = event || global.event;\n var self = this;\n\n if (this._localStorageChanged(event, INDEX_EMIT)) {\n this._transaction(function() {\n var now = Date.now();\n var data = localStorage.getItem(INDEX_EMIT);\n var messages;\n\n try {\n messages = JSON.parse(data || '[]');\n } catch(e) {\n messages = [];\n }\n for (var i = 0; i < messages.length; i++) {\n if (messages[i].origin === self.origin) continue;\n if (messages[i].timestamp < self.lastMessage) continue;\n if (messages[i].id) {\n if (self.receivedIDs.hasOwnProperty(messages[i].id)) continue;\n self.receivedIDs[messages[i].id] = true;\n }\n self.trigger(messages[i].name, messages[i].payload);\n }\n self.lastMessage = now;\n });\n }\n\n this._trigger('storage', event);\n};\n\nIntercom.prototype._emit = function(name, message, id) {\n id = (typeof id === 'string' || typeof id === 'number') ? String(id) : null;\n if (id && id.length) {\n if (this.receivedIDs.hasOwnProperty(id)) return;\n this.receivedIDs[id] = true;\n }\n\n var packet = {\n id : id,\n name : name,\n origin : this.origin,\n timestamp : Date.now(),\n payload : message\n };\n\n var self = this;\n this._transaction(function() {\n var data = localStorage.getItem(INDEX_EMIT) || '[]';\n var delimiter = (data === '[]') ? '' : ',';\n data = [data.substring(0, data.length - 1), delimiter, JSON.stringify(packet), ']'].join('');\n localStorage.setItem(INDEX_EMIT, data);\n self.trigger(name, message);\n\n setTimeout(function() {\n self._cleanup_emit();\n }, 50);\n });\n};\n\nIntercom.prototype.emit = function(name, message) {\n this._emit.apply(this, arguments);\n this._trigger('emit', name, message);\n};\n\nIntercom.prototype.once = function(key, fn, ttl) {\n if (!Intercom.supported) {\n return;\n }\n\n var self = this;\n this._transaction(function() {\n var data;\n try {\n data = JSON.parse(localStorage.getItem(INDEX_ONCE) || '{}');\n } catch(e) {\n data = {};\n }\n if (!self._once_expired(key, data)) {\n return;\n }\n\n data[key] = {};\n data[key].timestamp = Date.now();\n if (typeof ttl === 'number') {\n data[key].ttl = ttl * 1000;\n }\n\n localStorage.setItem(INDEX_ONCE, JSON.stringify(data));\n fn();\n\n setTimeout(function() {\n self._cleanup_once();\n }, 50);\n });\n};\n\nextend(Intercom.prototype, EventEmitter.prototype);\n\nIntercom.supported = (typeof localStorage !== 'undefined');\n\nvar INDEX_EMIT = 'intercom';\nvar INDEX_ONCE = 'intercom_once';\nvar INDEX_LOCK = 'intercom_lock';\n\nvar THRESHOLD_TTL_EMIT = 50000;\nvar THRESHOLD_TTL_ONCE = 1000 * 3600;\n\nIntercom.destroy = function() {\n localStorage.removeItem(INDEX_LOCK);\n localStorage.removeItem(INDEX_EMIT);\n localStorage.removeItem(INDEX_ONCE);\n};\n\nIntercom.getInstance = (function() {\n var intercom;\n return function() {\n if (!intercom) {\n intercom = new Intercom();\n }\n return intercom;\n };\n})();\n\nmodule.exports = Intercom;\n","var EventEmitter = require('../lib/eventemitter.js');\nvar Path = require('./path.js');\nvar Intercom = require('../lib/intercom.js');\n\n/**\n * FSWatcher based on node.js' FSWatcher\n * see https://github.com/joyent/node/blob/master/lib/fs.js\n */\nfunction FSWatcher() {\n EventEmitter.call(this);\n var self = this;\n var recursive = false;\n var recursivePathPrefix;\n var filename;\n\n function onchange(path) {\n // Watch for exact filename, or parent path when recursive is true.\n if(filename === path || (recursive && path.indexOf(recursivePathPrefix) === 0)) {\n self.trigger('change', 'change', path);\n }\n }\n\n // We support, but ignore the second arg, which node.js uses.\n self.start = function(filename_, persistent_, recursive_) {\n // Bail if we've already started (and therefore have a filename);\n if(filename) {\n return;\n }\n\n if(Path.isNull(filename_)) {\n throw new Error('Path must be a string without null bytes.');\n }\n\n // TODO: get realpath for symlinks on filename...\n\n // Filer's Path.normalize strips trailing slashes, which we use here.\n // See https://github.com/js-platform/filer/issues/105\n filename = Path.normalize(filename_);\n\n // Whether to watch beneath this path or not\n recursive = recursive_ === true;\n // If recursive, construct a path prefix portion for comparisons later\n // (i.e., '/path' becomes '/path/' so we can search within a filename for the\n // prefix). We also take care to allow for '/' on its own.\n if(recursive) {\n recursivePathPrefix = filename === '/' ? '/' : filename + '/';\n }\n\n var intercom = Intercom.getInstance();\n intercom.on('change', onchange);\n };\n\n self.close = function() {\n var intercom = Intercom.getInstance();\n intercom.off('change', onchange);\n self.removeAllListeners('change');\n };\n}\nFSWatcher.prototype = new EventEmitter();\nFSWatcher.prototype.constructor = FSWatcher;\n\nmodule.exports = FSWatcher;\n","var MODE_FILE = require('./constants.js').MODE_FILE;\n\nmodule.exports = function DirectoryEntry(id, type) {\n this.id = id;\n this.type = type || MODE_FILE;\n};\n","var Errors = require('./errors.js');\n\nfunction OpenFileDescription(path, id, flags, position) {\n this.path = path;\n this.id = id;\n this.flags = flags;\n this.position = position;\n}\n\n// Tries to find the node associated with an ofd's `id`.\n// If not found, an error is returned on the callback.\nOpenFileDescription.prototype.getNode = function(context, callback) {\n var id = this.id;\n var path = this.path;\n\n function check_if_node_exists(error, node) {\n if(error) {\n return callback(error);\n }\n\n if(!node) {\n return callback(new Errors.EBADF('file descriptor refers to unknown node', path));\n }\n\n callback(null, node);\n }\n\n context.getObject(id, check_if_node_exists);\n};\n\nmodule.exports = OpenFileDescription;\n","var Constants = require('./constants.js');\n\nfunction SuperNode(options) {\n var now = Date.now();\n\n this.id = Constants.SUPER_NODE_ID;\n this.mode = Constants.MODE_META;\n this.atime = options.atime || now;\n this.ctime = options.ctime || now;\n this.mtime = options.mtime || now;\n // root node id (randomly generated)\n this.rnode = options.rnode;\n}\n\nSuperNode.create = function(options, callback) {\n options.guid(function(err, rnode) {\n if(err) {\n callback(err);\n return;\n }\n options.rnode = options.rnode || rnode;\n callback(null, new SuperNode(options));\n });\n};\n\nmodule.exports = SuperNode;\n","var MODE_FILE = require('./constants.js').MODE_FILE;\n\nfunction Node(options) {\n var now = Date.now();\n\n this.id = options.id;\n this.mode = options.mode || MODE_FILE; // node type (file, directory, etc)\n this.size = options.size || 0; // size (bytes for files, entries for directories)\n this.atime = options.atime || now; // access time (will mirror ctime after creation)\n this.ctime = options.ctime || now; // creation/change time\n this.mtime = options.mtime || now; // modified time\n this.flags = options.flags || []; // file flags\n this.xattrs = options.xattrs || {}; // extended attributes\n this.nlinks = options.nlinks || 0; // links count\n this.version = options.version || 0; // node version\n this.blksize = undefined; // block size\n this.nblocks = 1; // blocks count\n this.data = options.data; // id for data object\n}\n\n// Make sure the options object has an id on property,\n// either from caller or one we generate using supplied guid fn.\nfunction ensureID(options, prop, callback) {\n if(options[prop]) {\n callback(null);\n } else {\n options.guid(function(err, id) {\n options[prop] = id;\n callback(err);\n });\n }\n}\n\nNode.create = function(options, callback) {\n // We expect both options.id and options.data to be provided/generated.\n ensureID(options, 'id', function(err) {\n if(err) {\n callback(err);\n return;\n }\n\n ensureID(options, 'data', function(err) {\n if(err) {\n callback(err);\n return;\n }\n\n callback(null, new Node(options));\n });\n });\n};\n\nmodule.exports = Node;\n","var Constants = require('./constants.js');\n\nfunction Stats(fileNode, devName) {\n this.node = fileNode.id;\n this.dev = devName;\n this.size = fileNode.size;\n this.nlinks = fileNode.nlinks;\n this.atime = fileNode.atime;\n this.mtime = fileNode.mtime;\n this.ctime = fileNode.ctime;\n this.type = fileNode.mode;\n}\n\nStats.prototype.isFile = function() {\n return this.type === Constants.MODE_FILE;\n};\n\nStats.prototype.isDirectory = function() {\n return this.type === Constants.MODE_DIRECTORY;\n};\n\nStats.prototype.isSymbolicLink = function() {\n return this.type === Constants.MODE_SYMBOLIC_LINK;\n};\n\n// These will always be false in Filer.\nStats.prototype.isSocket =\nStats.prototype.isFIFO =\nStats.prototype.isCharacterDevice =\nStats.prototype.isBlockDevice =\nfunction() {\n return false;\n};\n\nmodule.exports = Stats;\n","var _ = require('../../lib/nodash.js');\n\nvar Path = require('../path.js');\nvar normalize = Path.normalize;\nvar dirname = Path.dirname;\nvar basename = Path.basename;\nvar isAbsolutePath = Path.isAbsolute;\nvar isNullPath = Path.isNull;\n\nvar Constants = require('../constants.js');\nvar MODE_FILE = Constants.MODE_FILE;\nvar MODE_DIRECTORY = Constants.MODE_DIRECTORY;\nvar MODE_SYMBOLIC_LINK = Constants.MODE_SYMBOLIC_LINK;\nvar MODE_META = Constants.MODE_META;\n\nvar ROOT_DIRECTORY_NAME = Constants.ROOT_DIRECTORY_NAME;\nvar SUPER_NODE_ID = Constants.SUPER_NODE_ID;\nvar SYMLOOP_MAX = Constants.SYMLOOP_MAX;\n\nvar O_READ = Constants.O_READ;\nvar O_WRITE = Constants.O_WRITE;\nvar O_CREATE = Constants.O_CREATE;\nvar O_EXCLUSIVE = Constants.O_EXCLUSIVE;\nvar O_TRUNCATE = Constants.O_TRUNCATE;\nvar O_APPEND = Constants.O_APPEND;\nvar O_FLAGS = Constants.O_FLAGS;\n\nvar XATTR_CREATE = Constants.XATTR_CREATE;\nvar XATTR_REPLACE = Constants.XATTR_REPLACE;\nvar FS_NOMTIME = Constants.FS_NOMTIME;\nvar FS_NOCTIME = Constants.FS_NOCTIME;\n\nvar Encoding = require('../encoding.js');\nvar Errors = require('../errors.js');\nvar DirectoryEntry = require('../directory-entry.js');\nvar OpenFileDescription = require('../open-file-description.js');\nvar SuperNode = require('../super-node.js');\nvar Node = require('../node.js');\nvar Stats = require('../stats.js');\nvar Buffer = require('../buffer.js');\n\n/**\n * Update node times. Only passed times are modified (undefined times are ignored)\n * and filesystem flags are examined in order to override update logic.\n */\nfunction update_node_times(context, path, node, times, callback) {\n // Honour mount flags for how we update times\n var flags = context.flags;\n if(_(flags).contains(FS_NOCTIME)) {\n delete times.ctime;\n }\n if(_(flags).contains(FS_NOMTIME)) {\n delete times.mtime;\n }\n\n // Only do the update if required (i.e., times are still present)\n var update = false;\n if(times.ctime) {\n node.ctime = times.ctime;\n // We don't do atime tracking for perf reasons, but do mirror ctime\n node.atime = times.ctime;\n update = true;\n }\n if(times.atime) {\n // The only time we explicitly pass atime is when utimes(), futimes() is called.\n // Override ctime mirror here if so\n node.atime = times.atime;\n update = true;\n }\n if(times.mtime) {\n node.mtime = times.mtime;\n update = true;\n }\n\n function complete(error) {\n // Queue this change so we can send watch events.\n // Unlike node.js, we send the full path vs. basename/dirname only.\n context.changes.push({ event: 'change', path: path });\n callback(error);\n }\n\n if(update) {\n context.putObject(node.id, node, complete);\n } else {\n complete();\n }\n}\n\n/**\n * make_node()\n */\n// in: file or directory path\n// out: new node representing file/directory\nfunction make_node(context, path, mode, callback) {\n if(mode !== MODE_DIRECTORY && mode !== MODE_FILE) {\n return callback(new Errors.EINVAL('mode must be a directory or file', path));\n }\n\n path = normalize(path);\n\n var name = basename(path);\n var parentPath = dirname(path);\n var parentNode;\n var parentNodeData;\n var node;\n\n // Check if the parent node exists\n function create_node_in_parent(error, parentDirectoryNode) {\n if(error) {\n callback(error);\n } else if(parentDirectoryNode.mode !== MODE_DIRECTORY) {\n callback(new Errors.ENOTDIR('a component of the path prefix is not a directory', path));\n } else {\n parentNode = parentDirectoryNode;\n find_node(context, path, check_if_node_exists);\n }\n }\n\n // Check if the node to be created already exists\n function check_if_node_exists(error, result) {\n if(!error && result) {\n callback(new Errors.EEXIST('path name already exists', path));\n } else if(error && !(error instanceof Errors.ENOENT)) {\n callback(error);\n } else {\n context.getObject(parentNode.data, create_node);\n }\n }\n\n // Create the new node\n function create_node(error, result) {\n if(error) {\n callback(error);\n } else {\n parentNodeData = result;\n Node.create({guid: context.guid, mode: mode}, function(error, result) {\n if(error) {\n callback(error);\n return;\n }\n node = result;\n node.nlinks += 1;\n context.putObject(node.id, node, update_parent_node_data);\n });\n }\n }\n\n // Update parent node time\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n var now = Date.now();\n update_node_times(context, parentPath, node, { mtime: now, ctime: now }, callback);\n }\n }\n\n // Update the parent nodes data\n function update_parent_node_data(error) {\n if(error) {\n callback(error);\n } else {\n parentNodeData[name] = new DirectoryEntry(node.id, mode);\n context.putObject(parentNode.data, parentNodeData, update_time);\n }\n }\n\n // Find the parent node\n find_node(context, parentPath, create_node_in_parent);\n}\n\n/**\n * find_node\n */\n// in: file or directory path\n// out: node structure, or error\nfunction find_node(context, path, callback) {\n path = normalize(path);\n if(!path) {\n return callback(new Errors.ENOENT('path is an empty string'));\n }\n var name = basename(path);\n var parentPath = dirname(path);\n var followedCount = 0;\n\n function read_root_directory_node(error, superNode) {\n if(error) {\n callback(error);\n } else if(!superNode || superNode.mode !== MODE_META || !superNode.rnode) {\n callback(new Errors.EFILESYSTEMERROR());\n } else {\n context.getObject(superNode.rnode, check_root_directory_node);\n }\n }\n\n function check_root_directory_node(error, rootDirectoryNode) {\n if(error) {\n callback(error);\n } else if(!rootDirectoryNode) {\n callback(new Errors.ENOENT());\n } else {\n callback(null, rootDirectoryNode);\n }\n }\n\n // in: parent directory node\n // out: parent directory data\n function read_parent_directory_data(error, parentDirectoryNode) {\n if(error) {\n callback(error);\n } else if(parentDirectoryNode.mode !== MODE_DIRECTORY || !parentDirectoryNode.data) {\n callback(new Errors.ENOTDIR('a component of the path prefix is not a directory', path));\n } else {\n context.getObject(parentDirectoryNode.data, get_node_from_parent_directory_data);\n }\n }\n\n // in: parent directory data\n // out: searched node\n function get_node_from_parent_directory_data(error, parentDirectoryData) {\n if(error) {\n callback(error);\n } else {\n if(!_(parentDirectoryData).has(name)) {\n callback(new Errors.ENOENT(null, path));\n } else {\n var nodeId = parentDirectoryData[name].id;\n context.getObject(nodeId, is_symbolic_link);\n }\n }\n }\n\n function is_symbolic_link(error, node) {\n if(error) {\n callback(error);\n } else {\n if(node.mode == MODE_SYMBOLIC_LINK) {\n followedCount++;\n if(followedCount > SYMLOOP_MAX){\n callback(new Errors.ELOOP(null, path));\n } else {\n follow_symbolic_link(node.data);\n }\n } else {\n callback(null, node);\n }\n }\n }\n\n function follow_symbolic_link(data) {\n data = normalize(data);\n parentPath = dirname(data);\n name = basename(data);\n if(ROOT_DIRECTORY_NAME == name) {\n context.getObject(SUPER_NODE_ID, read_root_directory_node);\n } else {\n find_node(context, parentPath, read_parent_directory_data);\n }\n }\n\n if(ROOT_DIRECTORY_NAME == name) {\n context.getObject(SUPER_NODE_ID, read_root_directory_node);\n } else {\n find_node(context, parentPath, read_parent_directory_data);\n }\n}\n\n\n/**\n * set extended attribute (refactor)\n */\nfunction set_extended_attribute (context, path, node, name, value, flag, callback) {\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n update_node_times(context, path, node, { ctime: Date.now() }, callback);\n }\n }\n\n var xattrs = node.xattrs;\n\n if (flag === XATTR_CREATE && xattrs.hasOwnProperty(name)) {\n callback(new Errors.EEXIST('attribute already exists', path));\n }\n else if (flag === XATTR_REPLACE && !xattrs.hasOwnProperty(name)) {\n callback(new Errors.ENOATTR(null, path));\n }\n else {\n xattrs[name] = value;\n context.putObject(node.id, node, update_time);\n }\n}\n\n/**\n * ensure_root_directory. Creates a root node if necessary.\n *\n * Note: this should only be invoked when formatting a new file system.\n * Multiple invocations of this by separate instances will still result\n * in only a single super node.\n */\nfunction ensure_root_directory(context, callback) {\n var superNode;\n var directoryNode;\n var directoryData;\n\n function ensure_super_node(error, existingNode) {\n if(!error && existingNode) {\n // Another instance has beat us and already created the super node.\n callback();\n } else if(error && !(error instanceof Errors.ENOENT)) {\n callback(error);\n } else {\n SuperNode.create({guid: context.guid}, function(error, result) {\n if(error) {\n callback(error);\n return;\n }\n superNode = result;\n context.putObject(superNode.id, superNode, write_directory_node);\n });\n }\n }\n\n function write_directory_node(error) {\n if(error) {\n callback(error);\n } else {\n Node.create({guid: context.guid, id: superNode.rnode, mode: MODE_DIRECTORY}, function(error, result) {\n if(error) {\n callback(error);\n return;\n }\n directoryNode = result;\n directoryNode.nlinks += 1;\n context.putObject(directoryNode.id, directoryNode, write_directory_data);\n });\n }\n }\n\n function write_directory_data(error) {\n if(error) {\n callback(error);\n } else {\n directoryData = {};\n context.putObject(directoryNode.data, directoryData, callback);\n }\n }\n\n context.getObject(SUPER_NODE_ID, ensure_super_node);\n}\n\n/**\n * make_directory\n */\nfunction make_directory(context, path, callback) {\n path = normalize(path);\n var name = basename(path);\n var parentPath = dirname(path);\n\n var directoryNode;\n var directoryData;\n var parentDirectoryNode;\n var parentDirectoryData;\n\n function check_if_directory_exists(error, result) {\n if(!error && result) {\n callback(new Errors.EEXIST(null, path));\n } else if(error && !(error instanceof Errors.ENOENT)) {\n callback(error);\n } else {\n find_node(context, parentPath, read_parent_directory_data);\n }\n }\n\n function read_parent_directory_data(error, result) {\n if(error) {\n callback(error);\n } else {\n parentDirectoryNode = result;\n context.getObject(parentDirectoryNode.data, write_directory_node);\n }\n }\n\n function write_directory_node(error, result) {\n if(error) {\n callback(error);\n } else {\n parentDirectoryData = result;\n Node.create({guid: context.guid, mode: MODE_DIRECTORY}, function(error, result) {\n if(error) {\n callback(error);\n return;\n }\n directoryNode = result;\n directoryNode.nlinks += 1;\n context.putObject(directoryNode.id, directoryNode, write_directory_data);\n });\n }\n }\n\n function write_directory_data(error) {\n if(error) {\n callback(error);\n } else {\n directoryData = {};\n context.putObject(directoryNode.data, directoryData, update_parent_directory_data);\n }\n }\n\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n var now = Date.now();\n update_node_times(context, parentPath, parentDirectoryNode, { mtime: now, ctime: now }, callback);\n }\n }\n\n function update_parent_directory_data(error) {\n if(error) {\n callback(error);\n } else {\n parentDirectoryData[name] = new DirectoryEntry(directoryNode.id, MODE_DIRECTORY);\n context.putObject(parentDirectoryNode.data, parentDirectoryData, update_time);\n }\n }\n\n find_node(context, path, check_if_directory_exists);\n}\n\n/**\n * remove_directory\n */\nfunction remove_directory(context, path, callback) {\n path = normalize(path);\n var name = basename(path);\n var parentPath = dirname(path);\n\n var directoryNode;\n var directoryData;\n var parentDirectoryNode;\n var parentDirectoryData;\n\n function read_parent_directory_data(error, result) {\n if(error) {\n callback(error);\n } else {\n parentDirectoryNode = result;\n context.getObject(parentDirectoryNode.data, check_if_node_exists);\n }\n }\n\n function check_if_node_exists(error, result) {\n if(error) {\n callback(error);\n } else if(ROOT_DIRECTORY_NAME == name) {\n callback(new Errors.EBUSY(null, path));\n } else if(!_(result).has(name)) {\n callback(new Errors.ENOENT(null, path));\n } else {\n parentDirectoryData = result;\n directoryNode = parentDirectoryData[name].id;\n context.getObject(directoryNode, check_if_node_is_directory);\n }\n }\n\n function check_if_node_is_directory(error, result) {\n if(error) {\n callback(error);\n } else if(result.mode != MODE_DIRECTORY) {\n callback(new Errors.ENOTDIR(null, path));\n } else {\n directoryNode = result;\n context.getObject(directoryNode.data, check_if_directory_is_empty);\n }\n }\n\n function check_if_directory_is_empty(error, result) {\n if(error) {\n callback(error);\n } else {\n directoryData = result;\n if(_(directoryData).size() > 0) {\n callback(new Errors.ENOTEMPTY(null, path));\n } else {\n remove_directory_entry_from_parent_directory_node();\n }\n }\n }\n\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n var now = Date.now();\n update_node_times(context, parentPath, parentDirectoryNode, { mtime: now, ctime: now }, remove_directory_node);\n }\n }\n\n function remove_directory_entry_from_parent_directory_node() {\n delete parentDirectoryData[name];\n context.putObject(parentDirectoryNode.data, parentDirectoryData, update_time);\n }\n\n function remove_directory_node(error) {\n if(error) {\n callback(error);\n } else {\n context.delete(directoryNode.id, remove_directory_data);\n }\n }\n\n function remove_directory_data(error) {\n if(error) {\n callback(error);\n } else {\n context.delete(directoryNode.data, callback);\n }\n }\n\n find_node(context, parentPath, read_parent_directory_data);\n}\n\nfunction open_file(context, path, flags, callback) {\n path = normalize(path);\n var name = basename(path);\n var parentPath = dirname(path);\n\n var directoryNode;\n var directoryData;\n var directoryEntry;\n var fileNode;\n var fileData;\n\n var followedCount = 0;\n\n if(ROOT_DIRECTORY_NAME == name) {\n if(_(flags).contains(O_WRITE)) {\n callback(new Errors.EISDIR('the named file is a directory and O_WRITE is set', path));\n } else {\n find_node(context, path, set_file_node);\n }\n } else {\n find_node(context, parentPath, read_directory_data);\n }\n\n function read_directory_data(error, result) {\n if(error) {\n callback(error);\n } else if(result.mode !== MODE_DIRECTORY) {\n callback(new Errors.ENOENT(null, path));\n } else {\n directoryNode = result;\n context.getObject(directoryNode.data, check_if_file_exists);\n }\n }\n\n function check_if_file_exists(error, result) {\n if(error) {\n callback(error);\n } else {\n directoryData = result;\n if(_(directoryData).has(name)) {\n if(_(flags).contains(O_EXCLUSIVE)) {\n callback(new Errors.ENOENT('O_CREATE and O_EXCLUSIVE are set, and the named file exists', path));\n } else {\n directoryEntry = directoryData[name];\n if(directoryEntry.type == MODE_DIRECTORY && _(flags).contains(O_WRITE)) {\n callback(new Errors.EISDIR('the named file is a directory and O_WRITE is set', path));\n } else {\n context.getObject(directoryEntry.id, check_if_symbolic_link);\n }\n }\n } else {\n if(!_(flags).contains(O_CREATE)) {\n callback(new Errors.ENOENT('O_CREATE is not set and the named file does not exist', path));\n } else {\n write_file_node();\n }\n }\n }\n }\n\n function check_if_symbolic_link(error, result) {\n if(error) {\n callback(error);\n } else {\n var node = result;\n if(node.mode == MODE_SYMBOLIC_LINK) {\n followedCount++;\n if(followedCount > SYMLOOP_MAX){\n callback(new Errors.ELOOP(null, path));\n } else {\n follow_symbolic_link(node.data);\n }\n } else {\n set_file_node(undefined, node);\n }\n }\n }\n\n function follow_symbolic_link(data) {\n data = normalize(data);\n parentPath = dirname(data);\n name = basename(data);\n if(ROOT_DIRECTORY_NAME == name) {\n if(_(flags).contains(O_WRITE)) {\n callback(new Errors.EISDIR('the named file is a directory and O_WRITE is set', path));\n } else {\n find_node(context, path, set_file_node);\n }\n }\n find_node(context, parentPath, read_directory_data);\n }\n\n function set_file_node(error, result) {\n if(error) {\n callback(error);\n } else {\n fileNode = result;\n callback(null, fileNode);\n }\n }\n\n function write_file_node() {\n Node.create({guid: context.guid, mode: MODE_FILE}, function(error, result) {\n if(error) {\n callback(error);\n return;\n }\n fileNode = result;\n fileNode.nlinks += 1;\n context.putObject(fileNode.id, fileNode, write_file_data);\n });\n }\n\n function write_file_data(error) {\n if(error) {\n callback(error);\n } else {\n fileData = new Buffer(0);\n fileData.fill(0);\n context.putBuffer(fileNode.data, fileData, update_directory_data);\n }\n }\n\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n var now = Date.now();\n update_node_times(context, parentPath, directoryNode, { mtime: now, ctime: now }, handle_update_result);\n }\n }\n\n function update_directory_data(error) {\n if(error) {\n callback(error);\n } else {\n directoryData[name] = new DirectoryEntry(fileNode.id, MODE_FILE);\n context.putObject(directoryNode.data, directoryData, update_time);\n }\n }\n\n function handle_update_result(error) {\n if(error) {\n callback(error);\n } else {\n callback(null, fileNode);\n }\n }\n}\n\nfunction replace_data(context, ofd, buffer, offset, length, callback) {\n var fileNode;\n\n function return_nbytes(error) {\n if(error) {\n callback(error);\n } else {\n callback(null, length);\n }\n }\n\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n var now = Date.now();\n update_node_times(context, ofd.path, fileNode, { mtime: now, ctime: now }, return_nbytes);\n }\n }\n\n function update_file_node(error) {\n if(error) {\n callback(error);\n } else {\n context.putObject(fileNode.id, fileNode, update_time);\n }\n }\n\n function write_file_data(error, result) {\n if(error) {\n callback(error);\n } else {\n fileNode = result;\n var newData = new Buffer(length);\n newData.fill(0);\n buffer.copy(newData, 0, offset, offset + length);\n ofd.position = length;\n\n fileNode.size = length;\n fileNode.version += 1;\n\n context.putBuffer(fileNode.data, newData, update_file_node);\n }\n }\n\n context.getObject(ofd.id, write_file_data);\n}\n\nfunction write_data(context, ofd, buffer, offset, length, position, callback) {\n var fileNode;\n var fileData;\n\n function return_nbytes(error) {\n if(error) {\n callback(error);\n } else {\n callback(null, length);\n }\n }\n\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n var now = Date.now();\n update_node_times(context, ofd.path, fileNode, { mtime: now, ctime: now }, return_nbytes);\n }\n }\n\n function update_file_node(error) {\n if(error) {\n callback(error);\n } else {\n context.putObject(fileNode.id, fileNode, update_time);\n }\n }\n\n function update_file_data(error, result) {\n if(error) {\n callback(error);\n } else {\n fileData = result;\n if(!fileData) {\n return callback(new Errors.EIO('Expected Buffer'));\n }\n var _position = (!(undefined === position || null === position)) ? position : ofd.position;\n var newSize = Math.max(fileData.length, _position + length);\n var newData = new Buffer(newSize);\n newData.fill(0);\n if(fileData) {\n fileData.copy(newData);\n }\n buffer.copy(newData, _position, offset, offset + length);\n if(undefined === position) {\n ofd.position += length;\n }\n\n fileNode.size = newSize;\n fileNode.version += 1;\n\n context.putBuffer(fileNode.data, newData, update_file_node);\n }\n }\n\n function read_file_data(error, result) {\n if(error) {\n callback(error);\n } else {\n fileNode = result;\n context.getBuffer(fileNode.data, update_file_data);\n }\n }\n\n context.getObject(ofd.id, read_file_data);\n}\n\nfunction read_data(context, ofd, buffer, offset, length, position, callback) {\n var fileNode;\n var fileData;\n\n function handle_file_data(error, result) {\n if(error) {\n callback(error);\n } else {\n fileData = result;\n if(!fileData) {\n return callback(new Errors.EIO('Expected Buffer'));\n }\n var _position = (!(undefined === position || null === position)) ? position : ofd.position;\n length = (_position + length > buffer.length) ? length - _position : length;\n fileData.copy(buffer, offset, _position, _position + length);\n if(undefined === position) {\n ofd.position += length;\n }\n callback(null, length);\n }\n }\n\n function read_file_data(error, result) {\n if(error) {\n callback(error);\n } else if(result.mode === 'DIRECTORY') {\n callback(new Errors.EISDIR('the named file is a directory', ofd.path));\n } else {\n fileNode = result;\n context.getBuffer(fileNode.data, handle_file_data);\n }\n }\n\n context.getObject(ofd.id, read_file_data);\n}\n\nfunction stat_file(context, path, callback) {\n path = normalize(path);\n var name = basename(path);\n find_node(context, path, callback);\n}\n\nfunction fstat_file(context, ofd, callback) {\n ofd.getNode(context, callback);\n}\n\nfunction lstat_file(context, path, callback) {\n path = normalize(path);\n var name = basename(path);\n var parentPath = dirname(path);\n\n var directoryNode;\n var directoryData;\n\n if(ROOT_DIRECTORY_NAME == name) {\n find_node(context, path, callback);\n } else {\n find_node(context, parentPath, read_directory_data);\n }\n\n function read_directory_data(error, result) {\n if(error) {\n callback(error);\n } else {\n directoryNode = result;\n context.getObject(directoryNode.data, check_if_file_exists);\n }\n }\n\n function check_if_file_exists(error, result) {\n if(error) {\n callback(error);\n } else {\n directoryData = result;\n if(!_(directoryData).has(name)) {\n callback(new Errors.ENOENT('a component of the path does not name an existing file', path));\n } else {\n context.getObject(directoryData[name].id, callback);\n }\n }\n }\n}\n\nfunction link_node(context, oldpath, newpath, callback) {\n oldpath = normalize(oldpath);\n var oldname = basename(oldpath);\n var oldParentPath = dirname(oldpath);\n\n newpath = normalize(newpath);\n var newname = basename(newpath);\n var newParentPath = dirname(newpath);\n\n var oldDirectoryNode;\n var oldDirectoryData;\n var newDirectoryNode;\n var newDirectoryData;\n var fileNode;\n\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n update_node_times(context, newpath, fileNode, { ctime: Date.now() }, callback);\n }\n }\n\n function update_file_node(error, result) {\n if(error) {\n callback(error);\n } else {\n fileNode = result;\n fileNode.nlinks += 1;\n context.putObject(fileNode.id, fileNode, update_time);\n }\n }\n\n function read_directory_entry(error, result) {\n if(error) {\n callback(error);\n } else {\n context.getObject(newDirectoryData[newname].id, update_file_node);\n }\n }\n\n function check_if_new_file_exists(error, result) {\n if(error) {\n callback(error);\n } else {\n newDirectoryData = result;\n if(_(newDirectoryData).has(newname)) {\n callback(new Errors.EEXIST('newpath resolves to an existing file', newname));\n } else {\n newDirectoryData[newname] = oldDirectoryData[oldname];\n context.putObject(newDirectoryNode.data, newDirectoryData, read_directory_entry);\n }\n }\n }\n\n function read_new_directory_data(error, result) {\n if(error) {\n callback(error);\n } else {\n newDirectoryNode = result;\n context.getObject(newDirectoryNode.data, check_if_new_file_exists);\n }\n }\n\n function check_if_old_file_exists(error, result) {\n if(error) {\n callback(error);\n } else {\n oldDirectoryData = result;\n if(!_(oldDirectoryData).has(oldname)) {\n callback(new Errors.ENOENT('a component of either path prefix does not exist', oldname));\n } else if(oldDirectoryData[oldname].type === 'DIRECTORY') {\n callback(new Errors.EPERM('oldpath refers to a directory'));\n } else {\n find_node(context, newParentPath, read_new_directory_data);\n }\n }\n }\n\n function read_old_directory_data(error, result) {\n if(error) {\n callback(error);\n } else {\n oldDirectoryNode = result;\n context.getObject(oldDirectoryNode.data, check_if_old_file_exists);\n }\n }\n\n find_node(context, oldParentPath, read_old_directory_data);\n}\n\nfunction unlink_node(context, path, callback) {\n path = normalize(path);\n var name = basename(path);\n var parentPath = dirname(path);\n\n var directoryNode;\n var directoryData;\n var fileNode;\n\n function update_directory_data(error) {\n if(error) {\n callback(error);\n } else {\n delete directoryData[name];\n context.putObject(directoryNode.data, directoryData, function(error) {\n var now = Date.now();\n update_node_times(context, parentPath, directoryNode, { mtime: now, ctime: now }, callback);\n });\n }\n }\n\n function delete_file_data(error) {\n if(error) {\n callback(error);\n } else {\n context.delete(fileNode.data, update_directory_data);\n }\n }\n\n function update_file_node(error, result) {\n if(error) {\n callback(error);\n } else {\n fileNode = result;\n fileNode.nlinks -= 1;\n if(fileNode.nlinks < 1) {\n context.delete(fileNode.id, delete_file_data);\n } else {\n context.putObject(fileNode.id, fileNode, function(error) {\n update_node_times(context, path, fileNode, { ctime: Date.now() }, update_directory_data);\n });\n }\n }\n }\n\n function check_if_node_is_directory(error, result) {\n if(error) {\n callback(error);\n } else if(result.mode === 'DIRECTORY') {\n callback(new Errors.EPERM('unlink not permitted on directories', name));\n } else {\n update_file_node(null, result);\n }\n }\n\n function check_if_file_exists(error, result) {\n if(error) {\n callback(error);\n } else {\n directoryData = result;\n if(!_(directoryData).has(name)) {\n callback(new Errors.ENOENT('a component of the path does not name an existing file', name));\n } else {\n context.getObject(directoryData[name].id, check_if_node_is_directory);\n }\n }\n }\n\n function read_directory_data(error, result) {\n if(error) {\n callback(error);\n } else {\n directoryNode = result;\n context.getObject(directoryNode.data, check_if_file_exists);\n }\n }\n\n find_node(context, parentPath, read_directory_data);\n}\n\nfunction read_directory(context, path, callback) {\n path = normalize(path);\n var name = basename(path);\n\n var directoryNode;\n var directoryData;\n\n function handle_directory_data(error, result) {\n if(error) {\n callback(error);\n } else {\n directoryData = result;\n var files = Object.keys(directoryData);\n callback(null, files);\n }\n }\n\n function read_directory_data(error, result) {\n if(error) {\n callback(error);\n } else if(result.mode !== MODE_DIRECTORY) {\n callback(new Errors.ENOTDIR(null, path));\n } else {\n directoryNode = result;\n context.getObject(directoryNode.data, handle_directory_data);\n }\n }\n\n find_node(context, path, read_directory_data);\n}\n\nfunction make_symbolic_link(context, srcpath, dstpath, callback) {\n dstpath = normalize(dstpath);\n var name = basename(dstpath);\n var parentPath = dirname(dstpath);\n\n var directoryNode;\n var directoryData;\n var fileNode;\n\n if(ROOT_DIRECTORY_NAME == name) {\n callback(new Errors.EEXIST(null, name));\n } else {\n find_node(context, parentPath, read_directory_data);\n }\n\n function read_directory_data(error, result) {\n if(error) {\n callback(error);\n } else {\n directoryNode = result;\n context.getObject(directoryNode.data, check_if_file_exists);\n }\n }\n\n function check_if_file_exists(error, result) {\n if(error) {\n callback(error);\n } else {\n directoryData = result;\n if(_(directoryData).has(name)) {\n callback(new Errors.EEXIST(null, name));\n } else {\n write_file_node();\n }\n }\n }\n\n function write_file_node() {\n Node.create({guid: context.guid, mode: MODE_SYMBOLIC_LINK}, function(error, result) {\n if(error) {\n callback(error);\n return;\n }\n fileNode = result;\n fileNode.nlinks += 1;\n fileNode.size = srcpath.length;\n fileNode.data = srcpath;\n context.putObject(fileNode.id, fileNode, update_directory_data);\n });\n }\n\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n var now = Date.now();\n update_node_times(context, parentPath, directoryNode, { mtime: now, ctime: now }, callback);\n }\n }\n\n function update_directory_data(error) {\n if(error) {\n callback(error);\n } else {\n directoryData[name] = new DirectoryEntry(fileNode.id, MODE_SYMBOLIC_LINK);\n context.putObject(directoryNode.data, directoryData, update_time);\n }\n }\n}\n\nfunction read_link(context, path, callback) {\n path = normalize(path);\n var name = basename(path);\n var parentPath = dirname(path);\n\n var directoryNode;\n var directoryData;\n\n find_node(context, parentPath, read_directory_data);\n\n function read_directory_data(error, result) {\n if(error) {\n callback(error);\n } else {\n directoryNode = result;\n context.getObject(directoryNode.data, check_if_file_exists);\n }\n }\n\n function check_if_file_exists(error, result) {\n if(error) {\n callback(error);\n } else {\n directoryData = result;\n if(!_(directoryData).has(name)) {\n callback(new Errors.ENOENT('a component of the path does not name an existing file', name));\n } else {\n context.getObject(directoryData[name].id, check_if_symbolic);\n }\n }\n }\n\n function check_if_symbolic(error, result) {\n if(error) {\n callback(error);\n } else {\n if(result.mode != MODE_SYMBOLIC_LINK) {\n callback(new Errors.EINVAL('path not a symbolic link', path));\n } else {\n callback(null, result.data);\n }\n }\n }\n}\n\nfunction truncate_file(context, path, length, callback) {\n path = normalize(path);\n\n var fileNode;\n\n function read_file_data (error, node) {\n if (error) {\n callback(error);\n } else if(node.mode == MODE_DIRECTORY ) {\n callback(new Errors.EISDIR(null, path));\n } else{\n fileNode = node;\n context.getBuffer(fileNode.data, truncate_file_data);\n }\n }\n\n function truncate_file_data(error, fileData) {\n if (error) {\n callback(error);\n } else {\n if(!fileData) {\n return callback(new Errors.EIO('Expected Buffer'));\n }\n var data = new Buffer(length);\n data.fill(0);\n if(fileData) {\n fileData.copy(data);\n }\n context.putBuffer(fileNode.data, data, update_file_node);\n }\n }\n\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n var now = Date.now();\n update_node_times(context, path, fileNode, { mtime: now, ctime: now }, callback);\n }\n }\n\n function update_file_node (error) {\n if(error) {\n callback(error);\n } else {\n fileNode.size = length;\n fileNode.version += 1;\n context.putObject(fileNode.id, fileNode, update_time);\n }\n }\n\n if(length < 0) {\n callback(new Errors.EINVAL('length cannot be negative'));\n } else {\n find_node(context, path, read_file_data);\n }\n}\n\nfunction ftruncate_file(context, ofd, length, callback) {\n var fileNode;\n\n function read_file_data (error, node) {\n if (error) {\n callback(error);\n } else if(node.mode == MODE_DIRECTORY ) {\n callback(new Errors.EISDIR());\n } else{\n fileNode = node;\n context.getBuffer(fileNode.data, truncate_file_data);\n }\n }\n\n function truncate_file_data(error, fileData) {\n if (error) {\n callback(error);\n } else {\n var data;\n if(!fileData) {\n return callback(new Errors.EIO('Expected Buffer'));\n }\n if(fileData) {\n data = fileData.slice(0, length);\n } else {\n data = new Buffer(length);\n data.fill(0);\n }\n context.putBuffer(fileNode.data, data, update_file_node);\n }\n }\n\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n var now = Date.now();\n update_node_times(context, ofd.path, fileNode, { mtime: now, ctime: now }, callback);\n }\n }\n\n function update_file_node (error) {\n if(error) {\n callback(error);\n } else {\n fileNode.size = length;\n fileNode.version += 1;\n context.putObject(fileNode.id, fileNode, update_time);\n }\n }\n\n if(length < 0) {\n callback(new Errors.EINVAL('length cannot be negative'));\n } else {\n ofd.getNode(context, read_file_data);\n }\n}\n\nfunction utimes_file(context, path, atime, mtime, callback) {\n path = normalize(path);\n\n function update_times(error, node) {\n if (error) {\n callback(error);\n } else {\n update_node_times(context, path, node, { atime: atime, ctime: mtime, mtime: mtime }, callback);\n }\n }\n\n if (typeof atime != 'number' || typeof mtime != 'number') {\n callback(new Errors.EINVAL('atime and mtime must be number', path));\n }\n else if (atime < 0 || mtime < 0) {\n callback(new Errors.EINVAL('atime and mtime must be positive integers', path));\n }\n else {\n find_node(context, path, update_times);\n }\n}\n\nfunction futimes_file(context, ofd, atime, mtime, callback) {\n\n function update_times (error, node) {\n if (error) {\n callback(error);\n } else {\n update_node_times(context, ofd.path, node, { atime: atime, ctime: mtime, mtime: mtime }, callback);\n }\n }\n\n if (typeof atime != 'number' || typeof mtime != 'number') {\n callback(new Errors.EINVAL('atime and mtime must be a number'));\n }\n else if (atime < 0 || mtime < 0) {\n callback(new Errors.EINVAL('atime and mtime must be positive integers'));\n }\n else {\n ofd.getNode(context, update_times);\n }\n}\n\nfunction setxattr_file(context, path, name, value, flag, callback) {\n path = normalize(path);\n\n function setxattr(error, node) {\n if(error) {\n return callback(error);\n }\n set_extended_attribute(context, path, node, name, value, flag, callback);\n }\n\n if (typeof name != 'string') {\n callback(new Errors.EINVAL('attribute name must be a string', path));\n }\n else if (!name) {\n callback(new Errors.EINVAL('attribute name cannot be an empty string', path));\n }\n else if (flag !== null &&\n flag !== XATTR_CREATE && flag !== XATTR_REPLACE) {\n callback(new Errors.EINVAL('invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE', path));\n }\n else {\n find_node(context, path, setxattr);\n }\n}\n\nfunction fsetxattr_file (context, ofd, name, value, flag, callback) {\n function setxattr(error, node) {\n if(error) {\n return callback(error);\n }\n set_extended_attribute(context, ofd.path, node, name, value, flag, callback);\n }\n\n if (typeof name !== 'string') {\n callback(new Errors.EINVAL('attribute name must be a string'));\n }\n else if (!name) {\n callback(new Errors.EINVAL('attribute name cannot be an empty string'));\n }\n else if (flag !== null &&\n flag !== XATTR_CREATE && flag !== XATTR_REPLACE) {\n callback(new Errors.EINVAL('invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE'));\n }\n else {\n ofd.getNode(context, setxattr);\n }\n}\n\nfunction getxattr_file (context, path, name, callback) {\n path = normalize(path);\n\n function get_xattr(error, node) {\n if(error) {\n return callback(error);\n }\n\n var xattrs = node.xattrs;\n\n if (!xattrs.hasOwnProperty(name)) {\n callback(new Errors.ENOATTR(null, path));\n }\n else {\n callback(null, xattrs[name]);\n }\n }\n\n if (typeof name != 'string') {\n callback(new Errors.EINVAL('attribute name must be a string', path));\n }\n else if (!name) {\n callback(new Errors.EINVAL('attribute name cannot be an empty string', path));\n }\n else {\n find_node(context, path, get_xattr);\n }\n}\n\nfunction fgetxattr_file (context, ofd, name, callback) {\n\n function get_xattr (error, node) {\n if (error) {\n return callback(error);\n }\n\n var xattrs = node.xattrs;\n\n if (!xattrs.hasOwnProperty(name)) {\n callback(new Errors.ENOATTR());\n }\n else {\n callback(null, xattrs[name]);\n }\n }\n\n if (typeof name != 'string') {\n callback(new Errors.EINVAL());\n }\n else if (!name) {\n callback(new Errors.EINVAL('attribute name cannot be an empty string'));\n }\n else {\n ofd.getNode(context, get_xattr);\n }\n}\n\nfunction removexattr_file (context, path, name, callback) {\n path = normalize(path);\n\n function remove_xattr (error, node) {\n if (error) {\n return callback(error);\n }\n\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n update_node_times(context, path, node, { ctime: Date.now() }, callback);\n }\n }\n\n var xattrs = node.xattrs;\n\n if (!xattrs.hasOwnProperty(name)) {\n callback(new Errors.ENOATTR(null, path));\n }\n else {\n delete xattrs[name];\n context.putObject(node.id, node, update_time);\n }\n }\n\n if (typeof name !== 'string') {\n callback(new Errors.EINVAL('attribute name must be a string', path));\n }\n else if (!name) {\n callback(new Errors.EINVAL('attribute name cannot be an empty string', path));\n }\n else {\n find_node(context, path, remove_xattr);\n }\n}\n\nfunction fremovexattr_file (context, ofd, name, callback) {\n\n function remove_xattr (error, node) {\n if (error) {\n return callback(error);\n }\n\n function update_time(error) {\n if(error) {\n callback(error);\n } else {\n update_node_times(context, ofd.path, node, { ctime: Date.now() }, callback);\n }\n }\n\n var xattrs = node.xattrs;\n\n if (!xattrs.hasOwnProperty(name)) {\n callback(new Errors.ENOATTR());\n }\n else {\n delete xattrs[name];\n context.putObject(node.id, node, update_time);\n }\n }\n\n if (typeof name != 'string') {\n callback(new Errors.EINVAL('attribute name must be a string'));\n }\n else if (!name) {\n callback(new Errors.EINVAL('attribute name cannot be an empty string'));\n }\n else {\n ofd.getNode(context, remove_xattr);\n }\n}\n\nfunction validate_flags(flags) {\n if(!_(O_FLAGS).has(flags)) {\n return null;\n }\n return O_FLAGS[flags];\n}\n\nfunction validate_file_options(options, enc, fileMode){\n if(!options) {\n options = { encoding: enc, flag: fileMode };\n } else if(typeof options === \"function\") {\n options = { encoding: enc, flag: fileMode };\n } else if(typeof options === \"string\") {\n options = { encoding: options, flag: fileMode };\n }\n return options;\n}\n\nfunction pathCheck(path, callback) {\n var err;\n\n if(!path) {\n err = new Errors.EINVAL('Path must be a string', path);\n } else if(isNullPath(path)) {\n err = new Errors.EINVAL('Path must be a string without null bytes.', path);\n } else if(!isAbsolutePath(path)) {\n err = new Errors.EINVAL('Path must be absolute.', path);\n }\n\n if(err) {\n callback(err);\n return false;\n }\n return true;\n}\n\n\nfunction open(fs, context, path, flags, mode, callback) {\n // NOTE: we support the same signature as node with a `mode` arg,\n // but ignore it.\n callback = arguments[arguments.length - 1];\n if(!pathCheck(path, callback)) return;\n\n function check_result(error, fileNode) {\n if(error) {\n callback(error);\n } else {\n var position;\n if(_(flags).contains(O_APPEND)) {\n position = fileNode.size;\n } else {\n position = 0;\n }\n var openFileDescription = new OpenFileDescription(path, fileNode.id, flags, position);\n var fd = fs.allocDescriptor(openFileDescription);\n callback(null, fd);\n }\n }\n\n flags = validate_flags(flags);\n if(!flags) {\n callback(new Errors.EINVAL('flags is not valid'), path);\n }\n\n open_file(context, path, flags, check_result);\n}\n\nfunction close(fs, context, fd, callback) {\n if(!_(fs.openFiles).has(fd)) {\n callback(new Errors.EBADF());\n } else {\n fs.releaseDescriptor(fd);\n callback(null);\n }\n}\n\nfunction mknod(fs, context, path, mode, callback) {\n if(!pathCheck(path, callback)) return;\n make_node(context, path, mode, callback);\n}\n\nfunction mkdir(fs, context, path, mode, callback) {\n // NOTE: we support passing a mode arg, but we ignore it internally for now.\n callback = arguments[arguments.length - 1];\n if(!pathCheck(path, callback)) return;\n make_directory(context, path, callback);\n}\n\nfunction rmdir(fs, context, path, callback) {\n if(!pathCheck(path, callback)) return;\n remove_directory(context, path, callback);\n}\n\nfunction stat(fs, context, path, callback) {\n if(!pathCheck(path, callback)) return;\n\n function check_result(error, result) {\n if(error) {\n callback(error);\n } else {\n var stats = new Stats(result, fs.name);\n callback(null, stats);\n }\n }\n\n stat_file(context, path, check_result);\n}\n\nfunction fstat(fs, context, fd, callback) {\n function check_result(error, result) {\n if(error) {\n callback(error);\n } else {\n var stats = new Stats(result, fs.name);\n callback(null, stats);\n }\n }\n\n var ofd = fs.openFiles[fd];\n if(!ofd) {\n callback(new Errors.EBADF());\n } else {\n fstat_file(context, ofd, check_result);\n }\n}\n\nfunction link(fs, context, oldpath, newpath, callback) {\n if(!pathCheck(oldpath, callback)) return;\n if(!pathCheck(newpath, callback)) return;\n link_node(context, oldpath, newpath, callback);\n}\n\nfunction unlink(fs, context, path, callback) {\n if(!pathCheck(path, callback)) return;\n unlink_node(context, path, callback);\n}\n\nfunction read(fs, context, fd, buffer, offset, length, position, callback) {\n // Follow how node.js does this\n function wrapped_cb(err, bytesRead) {\n // Retain a reference to buffer so that it can't be GC'ed too soon.\n callback(err, bytesRead || 0, buffer);\n }\n\n offset = (undefined === offset) ? 0 : offset;\n length = (undefined === length) ? buffer.length - offset : length;\n callback = arguments[arguments.length - 1];\n\n var ofd = fs.openFiles[fd];\n if(!ofd) {\n callback(new Errors.EBADF());\n } else if(!_(ofd.flags).contains(O_READ)) {\n callback(new Errors.EBADF('descriptor does not permit reading'));\n } else {\n read_data(context, ofd, buffer, offset, length, position, wrapped_cb);\n }\n}\n\nfunction readFile(fs, context, path, options, callback) {\n callback = arguments[arguments.length - 1];\n options = validate_file_options(options, null, 'r');\n\n if(!pathCheck(path, callback)) return;\n\n var flags = validate_flags(options.flag || 'r');\n if(!flags) {\n return callback(new Errors.EINVAL('flags is not valid', path));\n }\n\n open_file(context, path, flags, function(err, fileNode) {\n if(err) {\n return callback(err);\n }\n var ofd = new OpenFileDescription(path, fileNode.id, flags, 0);\n var fd = fs.allocDescriptor(ofd);\n\n function cleanup() {\n fs.releaseDescriptor(fd);\n }\n\n fstat_file(context, ofd, function(err, fstatResult) {\n if(err) {\n cleanup();\n return callback(err);\n }\n\n var stats = new Stats(fstatResult, fs.name);\n\n if(stats.isDirectory()) {\n cleanup();\n return callback(new Errors.EISDIR('illegal operation on directory', path));\n }\n\n var size = stats.size;\n var buffer = new Buffer(size);\n buffer.fill(0);\n\n read_data(context, ofd, buffer, 0, size, 0, function(err, nbytes) {\n cleanup();\n\n if(err) {\n return callback(err);\n }\n\n var data;\n if(options.encoding === 'utf8') {\n data = Encoding.decode(buffer);\n } else {\n data = buffer;\n }\n callback(null, data);\n });\n });\n });\n}\n\nfunction write(fs, context, fd, buffer, offset, length, position, callback) {\n callback = arguments[arguments.length - 1];\n offset = (undefined === offset) ? 0 : offset;\n length = (undefined === length) ? buffer.length - offset : length;\n\n var ofd = fs.openFiles[fd];\n if(!ofd) {\n callback(new Errors.EBADF());\n } else if(!_(ofd.flags).contains(O_WRITE)) {\n callback(new Errors.EBADF('descriptor does not permit writing'));\n } else if(buffer.length - offset < length) {\n callback(new Errors.EIO('intput buffer is too small'));\n } else {\n write_data(context, ofd, buffer, offset, length, position, callback);\n }\n}\n\nfunction writeFile(fs, context, path, data, options, callback) {\n callback = arguments[arguments.length - 1];\n options = validate_file_options(options, 'utf8', 'w');\n\n if(!pathCheck(path, callback)) return;\n\n var flags = validate_flags(options.flag || 'w');\n if(!flags) {\n return callback(new Errors.EINVAL('flags is not valid', path));\n }\n\n data = data || '';\n if(typeof data === \"number\") {\n data = '' + data;\n }\n if(typeof data === \"string\" && options.encoding === 'utf8') {\n data = Encoding.encode(data);\n }\n\n open_file(context, path, flags, function(err, fileNode) {\n if(err) {\n return callback(err);\n }\n var ofd = new OpenFileDescription(path, fileNode.id, flags, 0);\n var fd = fs.allocDescriptor(ofd);\n\n replace_data(context, ofd, data, 0, data.length, function(err, nbytes) {\n fs.releaseDescriptor(fd);\n\n if(err) {\n return callback(err);\n }\n callback(null);\n });\n });\n}\n\nfunction appendFile(fs, context, path, data, options, callback) {\n callback = arguments[arguments.length - 1];\n options = validate_file_options(options, 'utf8', 'a');\n\n if(!pathCheck(path, callback)) return;\n\n var flags = validate_flags(options.flag || 'a');\n if(!flags) {\n return callback(new Errors.EINVAL('flags is not valid', path));\n }\n\n data = data || '';\n if(typeof data === \"number\") {\n data = '' + data;\n }\n if(typeof data === \"string\" && options.encoding === 'utf8') {\n data = Encoding.encode(data);\n }\n\n open_file(context, path, flags, function(err, fileNode) {\n if(err) {\n return callback(err);\n }\n var ofd = new OpenFileDescription(path, fileNode.id, flags, fileNode.size);\n var fd = fs.allocDescriptor(ofd);\n\n write_data(context, ofd, data, 0, data.length, ofd.position, function(err, nbytes) {\n fs.releaseDescriptor(fd);\n\n if(err) {\n return callback(err);\n }\n callback(null);\n });\n });\n}\n\nfunction exists(fs, context, path, callback) {\n function cb(err, stats) {\n callback(err ? false : true);\n }\n stat(fs, context, path, cb);\n}\n\nfunction getxattr(fs, context, path, name, callback) {\n if (!pathCheck(path, callback)) return;\n getxattr_file(context, path, name, callback);\n}\n\nfunction fgetxattr(fs, context, fd, name, callback) {\n var ofd = fs.openFiles[fd];\n if (!ofd) {\n callback(new Errors.EBADF());\n }\n else {\n fgetxattr_file(context, ofd, name, callback);\n }\n}\n\nfunction setxattr(fs, context, path, name, value, flag, callback) {\n if(typeof flag === 'function') {\n callback = flag;\n flag = null;\n }\n\n if (!pathCheck(path, callback)) return;\n setxattr_file(context, path, name, value, flag, callback);\n}\n\nfunction fsetxattr(fs, context, fd, name, value, flag, callback) {\n if(typeof flag === 'function') {\n callback = flag;\n flag = null;\n }\n\n var ofd = fs.openFiles[fd];\n if (!ofd) {\n callback(new Errors.EBADF());\n }\n else if (!_(ofd.flags).contains(O_WRITE)) {\n callback(new Errors.EBADF('descriptor does not permit writing'));\n }\n else {\n fsetxattr_file(context, ofd, name, value, flag, callback);\n }\n}\n\nfunction removexattr(fs, context, path, name, callback) {\n if (!pathCheck(path, callback)) return;\n removexattr_file(context, path, name, callback);\n}\n\nfunction fremovexattr(fs, context, fd, name, callback) {\n var ofd = fs.openFiles[fd];\n if (!ofd) {\n callback(new Errors.EBADF());\n }\n else if (!_(ofd.flags).contains(O_WRITE)) {\n callback(new Errors.EBADF('descriptor does not permit writing'));\n }\n else {\n fremovexattr_file(context, ofd, name, callback);\n }\n}\n\nfunction lseek(fs, context, fd, offset, whence, callback) {\n function update_descriptor_position(error, stats) {\n if(error) {\n callback(error);\n } else {\n if(stats.size + offset < 0) {\n callback(new Errors.EINVAL('resulting file offset would be negative'));\n } else {\n ofd.position = stats.size + offset;\n callback(null, ofd.position);\n }\n }\n }\n\n var ofd = fs.openFiles[fd];\n if(!ofd) {\n callback(new Errors.EBADF());\n }\n\n if('SET' === whence) {\n if(offset < 0) {\n callback(new Errors.EINVAL('resulting file offset would be negative'));\n } else {\n ofd.position = offset;\n callback(null, ofd.position);\n }\n } else if('CUR' === whence) {\n if(ofd.position + offset < 0) {\n callback(new Errors.EINVAL('resulting file offset would be negative'));\n } else {\n ofd.position += offset;\n callback(null, ofd.position);\n }\n } else if('END' === whence) {\n fstat_file(context, ofd, update_descriptor_position);\n } else {\n callback(new Errors.EINVAL('whence argument is not a proper value'));\n }\n}\n\nfunction readdir(fs, context, path, callback) {\n if(!pathCheck(path, callback)) return;\n read_directory(context, path, callback);\n}\n\nfunction utimes(fs, context, path, atime, mtime, callback) {\n if(!pathCheck(path, callback)) return;\n\n var currentTime = Date.now();\n atime = (atime) ? atime : currentTime;\n mtime = (mtime) ? mtime : currentTime;\n\n utimes_file(context, path, atime, mtime, callback);\n}\n\nfunction futimes(fs, context, fd, atime, mtime, callback) {\n var currentTime = Date.now();\n atime = (atime) ? atime : currentTime;\n mtime = (mtime) ? mtime : currentTime;\n\n var ofd = fs.openFiles[fd];\n if(!ofd) {\n callback(new Errors.EBADF());\n } else if(!_(ofd.flags).contains(O_WRITE)) {\n callback(new Errors.EBADF('descriptor does not permit writing'));\n } else {\n futimes_file(context, ofd, atime, mtime, callback);\n }\n}\n\nfunction rename(fs, context, oldpath, newpath, callback) {\n if(!pathCheck(oldpath, callback)) return;\n if(!pathCheck(newpath, callback)) return;\n\n oldpath = normalize(oldpath);\n newpath = normalize(newpath);\n\n var oldParentPath = Path.dirname(oldpath);\n var newParentPath = Path.dirname(oldpath);\n var oldName = Path.basename(oldpath);\n var newName = Path.basename(newpath);\n var oldParentDirectory, oldParentData;\n var newParentDirectory, newParentData;\n\n function update_times(error, newNode) {\n if(error) {\n callback(error);\n } else {\n update_node_times(context, newpath, newNode, { ctime: Date.now() }, callback);\n }\n }\n\n function read_new_directory(error) {\n if(error) {\n callback(error);\n } else {\n context.getObject(newParentData[newName].id, update_times);\n }\n }\n\n function update_old_parent_directory_data(error) {\n if(error) {\n callback(error);\n } else {\n if(oldParentDirectory.id === newParentDirectory.id) {\n oldParentData = newParentData;\n }\n delete oldParentData[oldName];\n context.putObject(oldParentDirectory.data, oldParentData, read_new_directory);\n }\n }\n\n function update_new_parent_directory_data(error) {\n if(error) {\n callback(error);\n } else {\n newParentData[newName] = oldParentData[oldName];\n context.putObject(newParentDirectory.data, newParentData, update_old_parent_directory_data);\n }\n }\n\n function check_if_new_directory_exists(error, result) {\n if(error) {\n callback(error);\n } else {\n newParentData = result;\n if(_(newParentData).has(newName)) {\n remove_directory(context, newpath, update_new_parent_directory_data);\n } else {\n update_new_parent_directory_data();\n }\n }\n }\n\n function read_new_parent_directory_data(error, result) {\n if(error) {\n callback(error);\n } else {\n newParentDirectory = result;\n context.getObject(newParentDirectory.data, check_if_new_directory_exists);\n }\n }\n\n function get_new_parent_directory(error, result) {\n if(error) {\n callback(error);\n } else {\n oldParentData = result;\n find_node(context, newParentPath, read_new_parent_directory_data);\n }\n }\n\n function read_parent_directory_data(error, result) {\n if(error) {\n callback(error);\n } else {\n oldParentDirectory = result;\n context.getObject(result.data, get_new_parent_directory);\n }\n }\n\n function unlink_old_file(error) {\n if(error) {\n callback(error);\n } else {\n unlink_node(context, oldpath, callback);\n }\n }\n\n function check_node_type(error, node) {\n if(error) {\n callback(error);\n } else if(node.mode === 'DIRECTORY') {\n find_node(context, oldParentPath, read_parent_directory_data);\n } else {\n link_node(context, oldpath, newpath, unlink_old_file);\n }\n }\n\n find_node(context, oldpath, check_node_type);\n}\n\nfunction symlink(fs, context, srcpath, dstpath, type, callback) {\n // NOTE: we support passing the `type` arg, but ignore it.\n callback = arguments[arguments.length - 1];\n if(!pathCheck(srcpath, callback)) return;\n if(!pathCheck(dstpath, callback)) return;\n make_symbolic_link(context, srcpath, dstpath, callback);\n}\n\nfunction readlink(fs, context, path, callback) {\n if(!pathCheck(path, callback)) return;\n read_link(context, path, callback);\n}\n\nfunction lstat(fs, context, path, callback) {\n if(!pathCheck(path, callback)) return;\n\n function check_result(error, result) {\n if(error) {\n callback(error);\n } else {\n var stats = new Stats(result, fs.name);\n callback(null, stats);\n }\n }\n\n lstat_file(context, path, check_result);\n}\n\nfunction truncate(fs, context, path, length, callback) {\n // NOTE: length is optional\n callback = arguments[arguments.length - 1];\n length = length || 0;\n\n if(!pathCheck(path, callback)) return;\n truncate_file(context, path, length, callback);\n}\n\nfunction ftruncate(fs, context, fd, length, callback) {\n // NOTE: length is optional\n callback = arguments[arguments.length - 1];\n length = length || 0;\n\n var ofd = fs.openFiles[fd];\n if(!ofd) {\n callback(new Errors.EBADF());\n } else if(!_(ofd.flags).contains(O_WRITE)) {\n callback(new Errors.EBADF('descriptor does not permit writing'));\n } else {\n ftruncate_file(context, ofd, length, callback);\n }\n}\n\nmodule.exports = {\n ensureRootDirectory: ensure_root_directory,\n open: open,\n close: close,\n mknod: mknod,\n mkdir: mkdir,\n rmdir: rmdir,\n unlink: unlink,\n stat: stat,\n fstat: fstat,\n link: link,\n read: read,\n readFile: readFile,\n write: write,\n writeFile: writeFile,\n appendFile: appendFile,\n exists: exists,\n getxattr: getxattr,\n fgetxattr: fgetxattr,\n setxattr: setxattr,\n fsetxattr: fsetxattr,\n removexattr: removexattr,\n fremovexattr: fremovexattr,\n lseek: lseek,\n readdir: readdir,\n utimes: utimes,\n futimes: futimes,\n rename: rename,\n symlink: symlink,\n readlink: readlink,\n lstat: lstat,\n truncate: truncate,\n ftruncate: ftruncate\n};\n","var _ = require('../../lib/nodash.js');\n\nvar isNullPath = require('../path.js').isNull;\nvar nop = require('../shared.js').nop;\n\nvar Constants = require('../constants.js');\nvar FILE_SYSTEM_NAME = Constants.FILE_SYSTEM_NAME;\nvar FS_FORMAT = Constants.FS_FORMAT;\nvar FS_READY = Constants.FS_READY;\nvar FS_PENDING = Constants.FS_PENDING;\nvar FS_ERROR = Constants.FS_ERROR;\nvar FS_NODUPEIDCHECK = Constants.FS_NODUPEIDCHECK;\n\nvar providers = require('../providers/index.js');\n\nvar Shell = require('../shell/shell.js');\nvar Intercom = require('../../lib/intercom.js');\nvar FSWatcher = require('../fs-watcher.js');\nvar Errors = require('../errors.js');\nvar defaultGuidFn = require('../shared.js').guid;\n\nvar STDIN = Constants.STDIN;\nvar STDOUT = Constants.STDOUT;\nvar STDERR = Constants.STDERR;\nvar FIRST_DESCRIPTOR = Constants.FIRST_DESCRIPTOR;\n\n// The core fs operations live on impl\nvar impl = require('./implementation.js');\n\n// node.js supports a calling pattern that leaves off a callback.\nfunction maybeCallback(callback) {\n if(typeof callback === \"function\") {\n return callback;\n }\n return function(err) {\n if(err) {\n throw err;\n }\n };\n}\n\n// Default callback that logs an error if passed in\nfunction defaultCallback(err) {\n if(err) {\n console.error('Filer error: ', err);\n }\n}\n\n/**\n * FileSystem\n *\n * A FileSystem takes an `options` object, which can specify a number of,\n * options. All options are optional, and include:\n *\n * name: the name of the file system, defaults to \"local\"\n *\n * flags: one or more flags to use when creating/opening the file system.\n * For example: \"FORMAT\" will cause the file system to be formatted.\n * No explicit flags are set by default.\n *\n * provider: an explicit storage provider to use for the file\n * system's database context provider. A number of context\n * providers are included (see /src/providers), and users\n * can write one of their own and pass it in to be used.\n * By default an IndexedDB provider is used.\n *\n * guid: a function for generating unique IDs for nodes in the filesystem.\n * Use this to override the built-in UUID generation. (Used mainly for tests).\n *\n * callback: a callback function to be executed when the file system becomes\n * ready for use. Depending on the context provider used, this might\n * be right away, or could take some time. The callback should expect\n * an `error` argument, which will be null if everything worked. Also\n * users should check the file system's `readyState` and `error`\n * properties to make sure it is usable.\n */\nfunction FileSystem(options, callback) {\n options = options || {};\n callback = callback || defaultCallback;\n\n var flags = options.flags;\n var guid = options.guid ? options.guid : defaultGuidFn;\n var provider = options.provider || new providers.Default(options.name || FILE_SYSTEM_NAME);\n // If we're given a provider, match its name unless we get an explicit name\n var name = options.name || provider.name;\n var forceFormatting = _(flags).contains(FS_FORMAT);\n\n var fs = this;\n fs.readyState = FS_PENDING;\n fs.name = name;\n fs.error = null;\n\n fs.stdin = STDIN;\n fs.stdout = STDOUT;\n fs.stderr = STDERR;\n\n // Expose Shell constructor\n this.Shell = Shell.bind(undefined, this);\n\n // Safely expose the list of open files and file\n // descriptor management functions\n var openFiles = {};\n var nextDescriptor = FIRST_DESCRIPTOR;\n Object.defineProperty(this, \"openFiles\", {\n get: function() { return openFiles; }\n });\n this.allocDescriptor = function(openFileDescription) {\n var fd = nextDescriptor ++;\n openFiles[fd] = openFileDescription;\n return fd;\n };\n this.releaseDescriptor = function(fd) {\n delete openFiles[fd];\n };\n\n // Safely expose the operation queue\n var queue = [];\n this.queueOrRun = function(operation) {\n var error;\n\n if(FS_READY == fs.readyState) {\n operation.call(fs);\n } else if(FS_ERROR == fs.readyState) {\n error = new Errors.EFILESYSTEMERROR('unknown error');\n } else {\n queue.push(operation);\n }\n\n return error;\n };\n function runQueued() {\n queue.forEach(function(operation) {\n operation.call(this);\n }.bind(fs));\n queue = null;\n }\n\n // We support the optional `options` arg from node, but ignore it\n this.watch = function(filename, options, listener) {\n if(isNullPath(filename)) {\n throw new Error('Path must be a string without null bytes.');\n }\n if(typeof options === 'function') {\n listener = options;\n options = {};\n }\n options = options || {};\n listener = listener || nop;\n\n var watcher = new FSWatcher();\n watcher.start(filename, false, options.recursive);\n watcher.on('change', listener);\n\n return watcher;\n };\n\n // Deal with various approaches to node ID creation\n function wrappedGuidFn(context) {\n return function(callback) {\n // Skip the duplicate ID check if asked to\n if(_(flags).contains(FS_NODUPEIDCHECK)) {\n callback(null, guid());\n return;\n }\n\n // Otherwise (default) make sure this id is unused first\n function guidWithCheck(callback) {\n var id = guid();\n context.getObject(id, function(err, value) {\n if(err) {\n callback(err);\n return;\n }\n\n // If this id is unused, use it, otherwise find another\n if(!value) {\n callback(null, id);\n } else {\n guidWithCheck(callback);\n }\n });\n }\n guidWithCheck(callback);\n };\n }\n\n // Let other instances (in this or other windows) know about\n // any changes to this fs instance.\n function broadcastChanges(changes) {\n if(!changes.length) {\n return;\n }\n var intercom = Intercom.getInstance();\n changes.forEach(function(change) {\n intercom.emit(change.event, change.path);\n });\n }\n\n // Open file system storage provider\n provider.open(function(err) {\n function complete(error) {\n function wrappedContext(methodName) {\n var context = provider[methodName]();\n context.flags = flags;\n context.changes = [];\n context.guid = wrappedGuidFn(context);\n\n // When the context is finished, let the fs deal with any change events\n context.close = function() {\n var changes = context.changes;\n broadcastChanges(changes);\n changes.length = 0;\n };\n\n return context;\n }\n\n // Wrap the provider so we can extend the context with fs flags and\n // an array of changes (e.g., watch event 'change' and 'rename' events\n // for paths updated during the lifetime of the context). From this\n // point forward we won't call open again, so it's safe to drop it.\n fs.provider = {\n openReadWriteContext: function() {\n return wrappedContext('getReadWriteContext');\n },\n openReadOnlyContext: function() {\n return wrappedContext('getReadOnlyContext');\n }\n };\n\n if(error) {\n fs.readyState = FS_ERROR;\n } else {\n fs.readyState = FS_READY;\n }\n runQueued();\n callback(error, fs);\n }\n\n if(err) {\n return complete(err);\n }\n\n var context = provider.getReadWriteContext();\n context.guid = wrappedGuidFn(context);\n\n // Mount the filesystem, formatting if necessary\n if(forceFormatting) {\n // Wipe the storage provider, then write root block\n context.clear(function(err) {\n if(err) {\n return complete(err);\n }\n impl.ensureRootDirectory(context, complete);\n });\n } else {\n // Use existing (or create new) root and mount\n impl.ensureRootDirectory(context, complete);\n }\n });\n}\n\n// Expose storage providers on FileSystem constructor\nFileSystem.providers = providers;\n\n/**\n * Public API for FileSystem\n */\n[\n 'open',\n 'close',\n 'mknod',\n 'mkdir',\n 'rmdir',\n 'stat',\n 'fstat',\n 'link',\n 'unlink',\n 'read',\n 'readFile',\n 'write',\n 'writeFile',\n 'appendFile',\n 'exists',\n 'lseek',\n 'readdir',\n 'rename',\n 'readlink',\n 'symlink',\n 'lstat',\n 'truncate',\n 'ftruncate',\n 'utimes',\n 'futimes',\n 'setxattr',\n 'getxattr',\n 'fsetxattr',\n 'fgetxattr',\n 'removexattr',\n 'fremovexattr'\n].forEach(function(methodName) {\n FileSystem.prototype[methodName] = function() {\n var fs = this;\n var args = Array.prototype.slice.call(arguments, 0);\n var lastArgIndex = args.length - 1;\n\n // We may or may not get a callback, and since node.js supports\n // fire-and-forget style fs operations, we have to dance a bit here.\n var missingCallback = typeof args[lastArgIndex] !== 'function';\n var callback = maybeCallback(args[lastArgIndex]);\n\n var error = fs.queueOrRun(function() {\n var context = fs.provider.openReadWriteContext();\n\n // Fail early if the filesystem is in an error state (e.g.,\n // provider failed to open.\n if(FS_ERROR === fs.readyState) {\n var err = new Errors.EFILESYSTEMERROR('filesystem unavailable, operation canceled');\n return callback.call(fs, err);\n }\n\n // Wrap the callback so we can explicitly close the context\n function complete() {\n context.close();\n callback.apply(fs, arguments);\n }\n\n // Either add or replace the callback with our wrapper complete()\n if(missingCallback) {\n args.push(complete);\n } else {\n args[lastArgIndex] = complete;\n }\n\n // Forward this call to the impl's version, using the following\n // call signature, with complete() as the callback/last-arg now:\n // fn(fs, context, arg0, arg1, ... , complete);\n var fnArgs = [fs, context].concat(args);\n impl[methodName].apply(null, fnArgs);\n });\n if(error) {\n callback(error);\n }\n };\n});\n\nmodule.exports = FileSystem;\n","module.exports = {\n FileSystem: require('./filesystem/interface.js'),\n Buffer: require('./buffer.js'),\n Path: require('./path.js'),\n Errors: require('./errors.js'),\n Shell: require('./shell/shell.js')\n};\n"]}