2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
( function ( f ) { if ( typeof exports === "object" && typeof module !== "undefined" ) { module . exports = f ( ) } else if ( typeof define === "function" && define . amd ) { define ( [ ] , f ) } else { var g ; if ( typeof window !== "undefined" ) { g = window } else if ( typeof global !== "undefined" ) { g = global } else if ( typeof self !== "undefined" ) { g = self } else { g = this } g . Filer = f ( ) } } ) ( function ( ) { var define , module , exports ; return ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( "Cannot find module '" + o + "'" ) ; throw f . code = "MODULE_NOT_FOUND" , f } var l = n [ o ] = { exports : { } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ? n : e ) } , l , l . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 : [ function ( require , module , exports ) {
2014-05-27 18:44:30 +00:00
/*global setImmediate: false, setTimeout: false, console: false */
/ * *
2014-09-09 19:05:10 +00:00
* async . js shim , based on https : //raw.github.com/caolan/async/master/lib/async.js Feb 18, 2014
2014-05-27 18:44:30 +00:00
* Used under MIT - https : //github.com/caolan/async/blob/master/LICENSE
* /
( function ( ) {
var async = { } ;
2014-09-09 19:05:10 +00:00
// async.js functions used in Filer
2014-05-27 18:44:30 +00:00
//// nextTick implementation with browser-compatible fallback ////
if ( typeof process === 'undefined' || ! ( process . nextTick ) ) {
if ( typeof setImmediate === 'function' ) {
async . nextTick = function ( fn ) {
// not a direct alias for IE10 compatibility
setImmediate ( fn ) ;
} ;
async . setImmediate = async . nextTick ;
}
else {
async . nextTick = function ( fn ) {
setTimeout ( fn , 0 ) ;
} ;
async . setImmediate = async . nextTick ;
}
}
else {
async . nextTick = process . nextTick ;
if ( typeof setImmediate !== 'undefined' ) {
async . setImmediate = function ( fn ) {
// not a direct alias for IE10 compatibility
setImmediate ( fn ) ;
} ;
2018-06-28 17:35:20 +00:00
=== === =
// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
// eslint-disable-next-line no-global-assign
parcelRequire = ( function ( modules , cache , entry , globalName ) {
// Save the require from previous bundle to this closure if any
var previousRequire = typeof parcelRequire === 'function' && parcelRequire ;
var nodeRequire = typeof require === 'function' && require ;
function newRequire ( name , jumped ) {
if ( ! cache [ name ] ) {
if ( ! modules [ name ] ) {
// if we cannot find the module within our internal map or
// cache jump to the current global require ie. the last bundle
// that was added to the page.
var currentRequire = typeof parcelRequire === 'function' && parcelRequire ;
if ( ! jumped && currentRequire ) {
return currentRequire ( name , true ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
// If there are other bundles on this page the require from the
// previous one is saved to 'previousRequire'. Repeat this as
// many times as there are bundles until the module is found or
// we exhaust the require chain.
if ( previousRequire ) {
return previousRequire ( name , true ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
// Try the node require function if it exists.
if ( nodeRequire && typeof name === 'string' ) {
return nodeRequire ( name ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
var err = new Error ( 'Cannot find module \'' + name + '\'' ) ;
err . code = 'MODULE_NOT_FOUND' ;
throw err ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
localRequire . resolve = resolve ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
} , { } ] , 2 : [ function ( require , module , exports ) {
2014-05-27 18:44:30 +00:00
// Based on https://github.com/diy/intercom.js/blob/master/lib/events.js
// Copyright 2012 DIY Co Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
2018-06-28 17:35:20 +00:00
=== === =
var module = cache [ name ] = new newRequire . Module ( name ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
modules [ name ] [ 0 ] . call ( module . exports , localRequire , module , module . exports , this ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
return cache [ name ] . exports ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function localRequire ( x ) {
return newRequire ( localRequire . resolve ( x ) ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function resolve ( x ) {
return modules [ name ] [ 1 ] [ x ] || x ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function Module ( moduleName ) {
this . id = moduleName ;
this . bundle = newRequire ;
this . exports = { } ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
newRequire . isParcelRequire = true ;
newRequire . Module = Module ;
newRequire . modules = modules ;
newRequire . cache = cache ;
newRequire . parent = previousRequire ;
newRequire . register = function ( id , exports ) {
modules [ id ] = [ function ( require , module ) {
module . exports = exports ;
} , { } ] ;
2014-05-27 18:44:30 +00:00
} ;
2018-06-28 17:35:20 +00:00
for ( var i = 0 ; i < entry . length ; i ++ ) {
newRequire ( entry [ i ] ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
} , { } ] , 3 : [ function ( require , module , exports ) {
2014-07-15 17:22:25 +00:00
( function ( global ) {
2014-05-27 18:44:30 +00:00
// Based on https://github.com/diy/intercom.js/blob/master/lib/intercom.js
// Copyright 2012 DIY Co Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
2015-06-29 16:29:46 +00:00
var EventEmitter = require ( './eventemitter.js' ) ;
var guid = require ( '../src/shared.js' ) . guid ;
2018-06-28 17:35:20 +00:00
=== === =
if ( entry . length ) {
// Expose entry point to Node, AMD or browser globals
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
var mainExports = newRequire ( entry [ entry . length - 1 ] ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// CommonJS
if ( typeof exports === "object" && typeof module !== "undefined" ) {
module . exports = mainExports ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// RequireJS
} else if ( typeof define === "function" && define . amd ) {
define ( function ( ) {
return mainExports ;
} ) ;
// <script>
} else if ( globalName ) {
this [ globalName ] = mainExports ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
// Override the current require with this new one
return newRequire ;
} ) ( { 13 : [ function ( require , module , exports ) {
var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Cherry-picked bits of underscore.js, lodash.js
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
/ * *
* Lo - Dash 2.4 . 0 < http : //lodash.com/>
* Copyright 2012 - 2013 The Dojo Foundation < http : //dojofoundation.org/>
* Based on Underscore . js 1.5 . 2 < http : //underscorejs.org/LICENSE>
* Copyright 2009 - 2013 Jeremy Ashkenas , DocumentCloud and Investigative Reporters & Editors
* Available under MIT license < http : //lodash.com/license>
* /
var ArrayProto = Array . prototype ;
var nativeForEach = ArrayProto . forEach ;
var nativeIndexOf = ArrayProto . indexOf ;
var nativeSome = ArrayProto . some ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var ObjProto = Object . prototype ;
var hasOwnProperty = ObjProto . hasOwnProperty ;
var nativeKeys = Object . keys ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var breaker = { } ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function has ( obj , key ) {
return hasOwnProperty . call ( obj , key ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
var keys = nativeKeys || function ( obj ) {
if ( obj !== Object ( obj ) ) throw new TypeError ( 'Invalid object' ) ;
var keys = [ ] ;
for ( var key in obj ) {
if ( has ( obj , key ) ) keys . push ( key ) ;
} return keys ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function size ( obj ) {
if ( obj == null ) return 0 ;
return obj . length === + obj . length ? obj . length : keys ( obj ) . length ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function identity ( value ) {
return value ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function each ( obj , iterator , context ) {
var i , length ;
if ( obj == null ) return ;
if ( nativeForEach && obj . forEach === nativeForEach ) {
obj . forEach ( iterator , context ) ;
} else if ( obj . length === + obj . length ) {
for ( i = 0 , length = obj . length ; i < length ; i ++ ) {
if ( iterator . call ( context , obj [ i ] , i , obj ) === breaker ) return ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} else {
var keys = keys ( obj ) ;
for ( i = 0 , length = keys . length ; i < length ; i ++ ) {
if ( iterator . call ( context , obj [ keys [ i ] ] , keys [ i ] , obj ) === breaker ) return ;
2014-05-27 18:44:30 +00:00
}
}
} ;
2018-06-28 17:35:20 +00:00
function any ( obj , iterator , context ) {
iterator || ( iterator = identity ) ;
var result = false ;
if ( obj == null ) return result ;
if ( nativeSome && obj . some === nativeSome ) return obj . some ( iterator , context ) ;
each ( obj , function ( value , index , list ) {
if ( result || ( result = iterator . call ( context , value , index , list ) ) ) return breaker ;
} ) ;
return ! ! result ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function contains ( obj , target ) {
if ( obj == null ) return false ;
if ( nativeIndexOf && obj . indexOf === nativeIndexOf ) return obj . indexOf ( target ) != - 1 ;
return any ( obj , function ( value ) {
return value === target ;
2014-05-27 18:44:30 +00:00
} ) ;
2018-06-28 17:35:20 +00:00
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function Wrapped ( value ) {
this . value = value ;
}
Wrapped . prototype . has = function ( key ) {
return has ( this . value , key ) ;
} ;
Wrapped . prototype . contains = function ( target ) {
return contains ( this . value , target ) ;
} ;
Wrapped . prototype . size = function ( ) {
return size ( this . value ) ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function nodash ( value ) {
// don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
return value && ( typeof value === 'undefined' ? 'undefined' : _typeof ( value ) ) == 'object' && ! Array . isArray ( value ) && hasOwnProperty . call ( value , '__wrapped__' ) ? value : new Wrapped ( value ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
module . exports = nodash ;
} , { } ] , 4 : [ function ( require , module , exports ) {
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Based on https://github.com/joyent/node/blob/41e53e557992a7d552a8e23de035f9463da25c99/lib/path.js
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// resolves . and .. elements in a path array with directory names there
// must be no slashes, empty elements, or device names (c:\) in the array
// (so also no leading and trailing slashes - it does not distinguish
// relative and absolute paths)
function normalizeArray ( parts , allowAboveRoot ) {
// if the path tries to go above the root, `up` ends up > 0
var up = 0 ;
for ( var i = parts . length - 1 ; i >= 0 ; i -- ) {
var last = parts [ i ] ;
if ( last === '.' ) {
parts . splice ( i , 1 ) ;
} else if ( last === '..' ) {
parts . splice ( i , 1 ) ;
up ++ ;
} else if ( up ) {
parts . splice ( i , 1 ) ;
up -- ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
// if the path is allowed to go above the root, restore leading ..s
if ( allowAboveRoot ) {
for ( ; up -- ; up ) {
parts . unshift ( '..' ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
return parts ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Split a filename into [root, dir, basename, ext], unix version
// 'root' is just a slash, or nothing.
var splitPathRe = /^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/ ;
var splitPath = function splitPath ( filename ) {
var result = splitPathRe . exec ( filename ) ;
return [ result [ 1 ] || '' , result [ 2 ] || '' , result [ 3 ] || '' , result [ 4 ] || '' ] ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// path.resolve([from ...], to)
function resolve ( ) {
var resolvedPath = '' ,
resolvedAbsolute = false ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
for ( var i = arguments . length - 1 ; i >= - 1 && ! resolvedAbsolute ; i -- ) {
// XXXidbfs: we don't have process.cwd() so we use '/' as a fallback
var path = i >= 0 ? arguments [ i ] : '/' ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Skip empty and invalid entries
if ( typeof path !== 'string' || ! path ) {
continue ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
resolvedPath = path + '/' + resolvedPath ;
resolvedAbsolute = path . charAt ( 0 ) === '/' ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Normalize the path
resolvedPath = normalizeArray ( resolvedPath . split ( '/' ) . filter ( function ( p ) {
return ! ! p ;
} ) , ! resolvedAbsolute ) . join ( '/' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
return ( resolvedAbsolute ? '/' : '' ) + resolvedPath || '.' ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// path.normalize(path)
function normalize ( path ) {
var isAbsolute = path . charAt ( 0 ) === '/' ,
trailingSlash = path . substr ( - 1 ) === '/' ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Normalize the path
path = normalizeArray ( path . split ( '/' ) . filter ( function ( p ) {
return ! ! p ;
} ) , ! isAbsolute ) . join ( '/' ) ;
if ( ! path && ! isAbsolute ) {
path = '.' ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
/ *
if ( path && trailingSlash ) {
path += '/' ;
}
* /
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
return ( isAbsolute ? '/' : '' ) + path ;
}
function join ( ) {
var paths = Array . prototype . slice . call ( arguments , 0 ) ;
return normalize ( paths . filter ( function ( p , index ) {
return p && typeof p === 'string' ;
} ) . join ( '/' ) ) ;
}
// path.relative(from, to)
function relative ( from , to ) {
from = exports . resolve ( from ) . substr ( 1 ) ;
to = exports . resolve ( to ) . substr ( 1 ) ;
function trim ( arr ) {
var start = 0 ;
for ( ; start < arr . length ; start ++ ) {
if ( arr [ start ] !== '' ) break ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
var end = arr . length - 1 ;
for ( ; end >= 0 ; end -- ) {
if ( arr [ end ] !== '' ) break ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
if ( start > end ) return [ ] ;
return arr . slice ( start , end - start + 1 ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var fromParts = trim ( from . split ( '/' ) ) ;
var toParts = trim ( to . split ( '/' ) ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var length = Math . min ( fromParts . length , toParts . length ) ;
var samePartsLength = length ;
for ( var i = 0 ; i < length ; i ++ ) {
if ( fromParts [ i ] !== toParts [ i ] ) {
samePartsLength = i ;
break ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var outputParts = [ ] ;
for ( var i = samePartsLength ; i < fromParts . length ; i ++ ) {
outputParts . push ( '..' ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
outputParts = outputParts . concat ( toParts . slice ( samePartsLength ) ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
return outputParts . join ( '/' ) ;
}
2014-06-09 14:40:50 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-06-09 14:40:50 +00:00
Intercom . destroy = function ( ) {
localStorage . removeItem ( INDEX _LOCK ) ;
localStorage . removeItem ( INDEX _EMIT ) ;
localStorage . removeItem ( INDEX _ONCE ) ;
} ;
Intercom . getInstance = ( function ( ) {
var intercom ;
return function ( ) {
if ( ! intercom ) {
intercom = new Intercom ( ) ;
}
return intercom ;
} ;
} ) ( ) ;
module . exports = Intercom ;
2015-06-29 16:29:46 +00:00
} ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } )
} , { "../src/shared.js" : 30 , "./eventemitter.js" : 2 } ] , 4 : [ function ( require , module , exports ) {
2014-06-09 14:40:50 +00:00
// Cherry-picked bits of underscore.js, lodash.js
/ * *
* Lo - Dash 2.4 . 0 < http : //lodash.com/>
* Copyright 2012 - 2013 The Dojo Foundation < http : //dojofoundation.org/>
* Based on Underscore . js 1.5 . 2 < http : //underscorejs.org/LICENSE>
* Copyright 2009 - 2013 Jeremy Ashkenas , DocumentCloud and Investigative Reporters & Editors
* Available under MIT license < http : //lodash.com/license>
* /
var ArrayProto = Array . prototype ;
var nativeForEach = ArrayProto . forEach ;
var nativeIndexOf = ArrayProto . indexOf ;
var nativeSome = ArrayProto . some ;
2018-06-28 17:35:20 +00:00
=== === =
function dirname ( path ) {
var result = splitPath ( path ) ,
root = result [ 0 ] ,
dir = result [ 1 ] ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-06-09 14:40:50 +00:00
2018-06-28 17:35:20 +00:00
if ( ! root && ! dir ) {
// No dirname whatsoever
return '.' ;
}
2014-06-09 14:40:50 +00:00
2018-06-28 17:35:20 +00:00
if ( dir ) {
// It has a dirname, strip trailing slash
dir = dir . substr ( 0 , dir . length - 1 ) ;
}
2014-06-09 14:40:50 +00:00
2018-06-28 17:35:20 +00:00
return root + dir ;
2014-06-09 14:40:50 +00:00
}
2018-06-28 17:35:20 +00:00
function basename ( path , ext ) {
var f = splitPath ( path ) [ 2 ] ;
// TODO: make this comparison case-insensitive on windows?
if ( ext && f . substr ( - 1 * ext . length ) === ext ) {
f = f . substr ( 0 , f . length - ext . length ) ;
}
// XXXidbfs: node.js just does `return f`
return f === "" ? "/" : f ;
2014-06-09 14:40:50 +00:00
}
2018-06-28 17:35:20 +00:00
function extname ( path ) {
return splitPath ( path ) [ 3 ] ;
2014-06-09 14:40:50 +00:00
}
2018-06-28 17:35:20 +00:00
function isAbsolute ( path ) {
if ( path . charAt ( 0 ) === '/' ) {
return true ;
2014-06-09 14:40:50 +00:00
}
2018-06-28 17:35:20 +00:00
return false ;
}
2014-06-09 14:40:50 +00:00
2018-06-28 17:35:20 +00:00
function isNull ( path ) {
if ( ( '' + path ) . indexOf ( '\0' ) !== - 1 ) {
return true ;
}
return false ;
}
2014-06-09 14:40:50 +00:00
2018-06-28 17:35:20 +00:00
// XXXidbfs: we don't support path.exists() or path.existsSync(), which
// are deprecated, and need a FileSystem instance to work. Use fs.stat().
2014-06-09 14:40:50 +00:00
2018-06-28 17:35:20 +00:00
module . exports = {
normalize : normalize ,
resolve : resolve ,
join : join ,
relative : relative ,
sep : '/' ,
delimiter : ':' ,
dirname : dirname ,
basename : basename ,
extname : extname ,
isAbsolute : isAbsolute ,
isNull : isNull
2014-06-09 14:40:50 +00:00
} ;
2018-06-28 17:35:20 +00:00
} , { } ] , 14 : [ function ( require , module , exports ) {
function guid ( ) {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' . replace ( /[xy]/g , function ( c ) {
var r = Math . random ( ) * 16 | 0 ,
v = c == 'x' ? r : r & 0x3 | 0x8 ;
return v . toString ( 16 ) ;
} ) . toUpperCase ( ) ;
}
2014-06-09 14:40:50 +00:00
2018-06-28 17:35:20 +00:00
function nop ( ) { }
/ * *
* Convert a Uint8Array to a regular array
* /
function u8toArray ( u8 ) {
var array = [ ] ;
var len = u8 . length ;
for ( var i = 0 ; i < len ; i ++ ) {
array [ i ] = u8 [ i ] ;
}
return array ;
2014-06-09 14:40:50 +00:00
}
2018-06-28 17:35:20 +00:00
module . exports = {
guid : guid ,
u8toArray : u8toArray ,
nop : nop
} ;
} , { } ] , 15 : [ function ( require , module , exports ) {
var O _READ = 'READ' ;
var O _WRITE = 'WRITE' ;
var O _CREATE = 'CREATE' ;
var O _EXCLUSIVE = 'EXCLUSIVE' ;
var O _TRUNCATE = 'TRUNCATE' ;
var O _APPEND = 'APPEND' ;
var XATTR _CREATE = 'CREATE' ;
var XATTR _REPLACE = 'REPLACE' ;
2014-06-09 14:40:50 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
} , { } ] , 5 : [ function ( require , module , exports ) {
2014-08-17 05:56:03 +00:00
/ *
* base64 - arraybuffer
* https : //github.com/niklasvh/base64-arraybuffer
*
* Copyright ( c ) 2012 Niklas von Hertzen
* Licensed under the MIT license .
* /
2018-05-29 18:03:59 +00:00
( function ( ) {
2014-08-17 05:56:03 +00:00
"use strict" ;
2018-06-28 17:35:20 +00:00
=== === =
module . exports = {
FILE _SYSTEM _NAME : 'local' ,
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ;
// Use a lookup table to find the index.
var lookup = new Uint8Array ( 256 ) ;
for ( var i = 0 ; i < chars . length ; i ++ ) {
lookup [ chars . charCodeAt ( i ) ] = i ;
}
2014-08-17 05:56:03 +00:00
exports . encode = function ( arraybuffer ) {
var bytes = new Uint8Array ( arraybuffer ) ,
i , len = bytes . length , base64 = "" ;
2018-06-28 17:35:20 +00:00
=== === =
FILE _STORE _NAME : 'files' ,
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
IDB _RO : 'readonly' ,
IDB _RW : 'readwrite' ,
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
WSQL _VERSION : "1" ,
WSQL _SIZE : 5 * 1024 * 1024 ,
WSQL _DESC : "FileSystem Storage" ,
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
MODE _FILE : 'FILE' ,
MODE _DIRECTORY : 'DIRECTORY' ,
MODE _SYMBOLIC _LINK : 'SYMLINK' ,
MODE _META : 'META' ,
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
SYMLOOP _MAX : 10 ,
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
BINARY _MIME _TYPE : 'application/octet-stream' ,
JSON _MIME _TYPE : 'application/json' ,
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
ROOT _DIRECTORY _NAME : '/' , // basename(normalize(path))
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-08-17 05:56:03 +00:00
for ( i = 0 ; i < len ; i += 4 ) {
2018-05-29 18:03:59 +00:00
encoded1 = lookup [ base64 . charCodeAt ( i ) ] ;
encoded2 = lookup [ base64 . charCodeAt ( i + 1 ) ] ;
encoded3 = lookup [ base64 . charCodeAt ( i + 2 ) ] ;
encoded4 = lookup [ base64 . charCodeAt ( i + 3 ) ] ;
2018-06-28 17:35:20 +00:00
=== === =
// FS Mount Flags
FS _FORMAT : 'FORMAT' ,
FS _NOCTIME : 'NOCTIME' ,
FS _NOMTIME : 'NOMTIME' ,
FS _NODUPEIDCHECK : 'FS_NODUPEIDCHECK' ,
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
// FS File Open Flags
O _READ : O _READ ,
O _WRITE : O _WRITE ,
O _CREATE : O _CREATE ,
O _EXCLUSIVE : O _EXCLUSIVE ,
O _TRUNCATE : O _TRUNCATE ,
O _APPEND : O _APPEND ,
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-08-17 05:56:03 +00:00
return arraybuffer ;
} ;
2018-05-29 18:03:59 +00:00
} ) ( ) ;
2018-06-28 17:35:20 +00:00
=== === =
O _FLAGS : {
'r' : [ O _READ ] ,
'r+' : [ O _READ , O _WRITE ] ,
'w' : [ O _WRITE , O _CREATE , O _TRUNCATE ] ,
'w+' : [ O _WRITE , O _READ , O _CREATE , O _TRUNCATE ] ,
'wx' : [ O _WRITE , O _CREATE , O _EXCLUSIVE , O _TRUNCATE ] ,
'wx+' : [ O _WRITE , O _READ , O _CREATE , O _EXCLUSIVE , O _TRUNCATE ] ,
'a' : [ O _WRITE , O _CREATE , O _APPEND ] ,
'a+' : [ O _WRITE , O _READ , O _CREATE , O _APPEND ] ,
'ax' : [ O _WRITE , O _CREATE , O _EXCLUSIVE , O _APPEND ] ,
'ax+' : [ O _WRITE , O _READ , O _CREATE , O _EXCLUSIVE , O _APPEND ]
} ,
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
} , { } ] , 6 : [ function ( require , module , exports ) {
2018-05-29 18:03:59 +00:00
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' ;
; ( function ( exports ) {
'use strict' ;
var Arr = ( typeof Uint8Array !== 'undefined' )
? Uint8Array
: Array
var PLUS = '+' . charCodeAt ( 0 )
var SLASH = '/' . charCodeAt ( 0 )
var NUMBER = '0' . charCodeAt ( 0 )
var LOWER = 'a' . charCodeAt ( 0 )
var UPPER = 'A' . charCodeAt ( 0 )
var PLUS _URL _SAFE = '-' . charCodeAt ( 0 )
var SLASH _URL _SAFE = '_' . charCodeAt ( 0 )
function decode ( elt ) {
var code = elt . charCodeAt ( 0 )
if ( code === PLUS ||
code === PLUS _URL _SAFE )
return 62 // '+'
if ( code === SLASH ||
code === SLASH _URL _SAFE )
return 63 // '/'
if ( code < NUMBER )
return - 1 //no match
if ( code < NUMBER + 10 )
return code - NUMBER + 26 + 26
if ( code < UPPER + 26 )
return code - UPPER
if ( code < LOWER + 26 )
return code - LOWER + 26
}
function b64ToByteArray ( b64 ) {
var i , j , l , tmp , placeHolders , arr
if ( b64 . length % 4 > 0 ) {
throw new Error ( 'Invalid string. Length must be a multiple of 4' )
}
// the number of equal signs (place holders)
// if there are two placeholders, than the two characters before it
// represent one byte
// if there is only one, then the three characters before it represent 2 bytes
// this is just a cheap hack to not do indexOf twice
var len = b64 . length
placeHolders = '=' === b64 . charAt ( len - 2 ) ? 2 : '=' === b64 . charAt ( len - 1 ) ? 1 : 0
// base64 is 4/3 + up to two characters of the original data
arr = new Arr ( b64 . length * 3 / 4 - placeHolders )
// if there are placeholders, only get up to the last complete 4 chars
l = placeHolders > 0 ? b64 . length - 4 : b64 . length
var L = 0
function push ( v ) {
arr [ L ++ ] = v
}
for ( i = 0 , j = 0 ; i < l ; i += 4 , j += 3 ) {
tmp = ( decode ( b64 . charAt ( i ) ) << 18 ) | ( decode ( b64 . charAt ( i + 1 ) ) << 12 ) | ( decode ( b64 . charAt ( i + 2 ) ) << 6 ) | decode ( b64 . charAt ( i + 3 ) )
push ( ( tmp & 0xFF0000 ) >> 16 )
push ( ( tmp & 0xFF00 ) >> 8 )
push ( tmp & 0xFF )
}
if ( placeHolders === 2 ) {
tmp = ( decode ( b64 . charAt ( i ) ) << 2 ) | ( decode ( b64 . charAt ( i + 1 ) ) >> 4 )
push ( tmp & 0xFF )
} else if ( placeHolders === 1 ) {
tmp = ( decode ( b64 . charAt ( i ) ) << 10 ) | ( decode ( b64 . charAt ( i + 1 ) ) << 4 ) | ( decode ( b64 . charAt ( i + 2 ) ) >> 2 )
push ( ( tmp >> 8 ) & 0xFF )
push ( tmp & 0xFF )
}
return arr
}
function uint8ToBase64 ( uint8 ) {
var i ,
extraBytes = uint8 . length % 3 , // if we have 1 byte left, pad 2 bytes
output = "" ,
temp , length
function encode ( num ) {
return lookup . charAt ( num )
}
function tripletToBase64 ( num ) {
return encode ( num >> 18 & 0x3F ) + encode ( num >> 12 & 0x3F ) + encode ( num >> 6 & 0x3F ) + encode ( num & 0x3F )
}
// go through the array every three bytes, we'll deal with trailing stuff later
for ( i = 0 , length = uint8 . length - extraBytes ; i < length ; i += 3 ) {
temp = ( uint8 [ i ] << 16 ) + ( uint8 [ i + 1 ] << 8 ) + ( uint8 [ i + 2 ] )
output += tripletToBase64 ( temp )
}
// pad the end with zeros, but make sure to not forget the extra bytes
switch ( extraBytes ) {
case 1 :
temp = uint8 [ uint8 . length - 1 ]
output += encode ( temp >> 2 )
output += encode ( ( temp << 4 ) & 0x3F )
output += '=='
break
case 2 :
temp = ( uint8 [ uint8 . length - 2 ] << 8 ) + ( uint8 [ uint8 . length - 1 ] )
output += encode ( temp >> 10 )
output += encode ( ( temp >> 4 ) & 0x3F )
output += encode ( ( temp << 2 ) & 0x3F )
output += '='
break
}
return output
}
exports . toByteArray = b64ToByteArray
exports . fromByteArray = uint8ToBase64
} ( typeof exports === 'undefined' ? ( this . base64js = { } ) : exports ) )
} , { } ] , 7 : [ function ( require , module , exports ) {
( function ( global ) {
2014-06-10 18:53:04 +00:00
/ * !
* The buffer module from node . js , for the browser .
*
* @ author Feross Aboukhadijeh < feross @ feross . org > < http : //feross.org>
* @ license MIT
* /
2018-05-29 18:03:59 +00:00
/* eslint-disable no-proto */
'use strict'
2014-06-10 18:53:04 +00:00
2015-06-29 16:29:46 +00:00
var base64 = require ( 'base64-js' )
var ieee754 = require ( 'ieee754' )
2018-05-29 18:03:59 +00:00
var isArray = require ( 'isarray' )
2014-06-10 18:53:04 +00:00
exports . Buffer = Buffer
2015-06-29 16:29:46 +00:00
exports . SlowBuffer = SlowBuffer
2014-06-10 18:53:04 +00:00
exports . INSPECT _MAX _BYTES = 50
2015-05-31 15:18:20 +00:00
Buffer . poolSize = 8192 // not used by this implementation
2015-06-29 16:29:46 +00:00
var rootParent = { }
2018-06-28 17:35:20 +00:00
=== === =
XATTR _CREATE : XATTR _CREATE ,
XATTR _REPLACE : XATTR _REPLACE ,
FS _READY : 'READY' ,
FS _PENDING : 'PENDING' ,
FS _ERROR : 'ERROR' ,
SUPER _NODE _ID : '00000000-0000-0000-0000-000000000000' ,
// Reserved File Descriptors for streams
STDIN : 0 ,
STDOUT : 1 ,
STDERR : 2 ,
FIRST _DESCRIPTOR : 3 ,
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
ENVIRONMENT : {
TMP : '/tmp' ,
PATH : ''
}
} ;
} , { } ] , 5 : [ function ( require , module , exports ) {
var errors = { } ;
[
2014-06-10 18:53:04 +00:00
/ * *
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-05-31 15:18:20 +00:00
* If ` Buffer.TYPED_ARRAY_SUPPORT ` :
2014-06-10 18:53:04 +00:00
* === true Use Uint8Array implementation ( fastest )
2015-05-31 15:18:20 +00:00
* === false Use Object implementation ( most compatible , even IE6 )
*
* Browsers that support typed arrays are IE 10 + , Firefox 4 + , Chrome 7 + , Safari 5.1 + ,
* Opera 11.6 + , iOS 4.2 + .
*
2018-05-29 18:03:59 +00:00
* Due to various browser bugs , sometimes the Object implementation will be used even
* when the browser supports typed arrays .
*
2015-05-31 15:18:20 +00:00
* Note :
*
2018-05-29 18:03:59 +00:00
* - Firefox 4 - 29 lacks support for adding new properties to ` Uint8Array ` instances ,
* See : https : //bugzilla.mozilla.org/show_bug.cgi?id=695438.
2015-05-31 15:18:20 +00:00
*
2018-05-29 18:03:59 +00:00
* - Safari 5 - 7 lacks support for changing the ` Object.prototype.constructor ` property
* on objects .
2015-05-31 15:18:20 +00:00
*
2018-05-29 18:03:59 +00:00
* - Chrome 9 - 10 is missing the ` TypedArray.prototype.subarray ` function .
2015-05-31 15:18:20 +00:00
*
2018-05-29 18:03:59 +00:00
* - IE10 has a broken ` TypedArray.prototype.subarray ` function which returns arrays of
* incorrect length in some situations .
* We detect these buggy browsers and set ` Buffer.TYPED_ARRAY_SUPPORT ` to ` false ` so they
* get the Object implementation , which is slower but behaves correctly .
2014-06-10 18:53:04 +00:00
* /
2018-05-29 18:03:59 +00:00
Buffer . TYPED _ARRAY _SUPPORT = global . TYPED _ARRAY _SUPPORT !== undefined
? global . TYPED _ARRAY _SUPPORT
: typedArraySupport ( )
function typedArraySupport ( ) {
function Bar ( ) { }
2014-06-10 18:53:04 +00:00
try {
2018-05-29 18:03:59 +00:00
var arr = new Uint8Array ( 1 )
2014-06-10 18:53:04 +00:00
arr . foo = function ( ) { return 42 }
2018-05-29 18:03:59 +00:00
arr . constructor = Bar
2015-06-29 16:29:46 +00:00
return arr . foo ( ) === 42 && // typed array instances can be augmented
2018-05-29 18:03:59 +00:00
arr . constructor === Bar && // constructor can be set
2015-05-31 15:18:20 +00:00
typeof arr . subarray === 'function' && // chrome 9-10 lack `subarray`
2018-05-29 18:03:59 +00:00
arr . subarray ( 1 , 1 ) . byteLength === 0 // ie10 has broken `subarray`
2014-06-10 18:53:04 +00:00
} catch ( e ) {
return false
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
}
function kMaxLength ( ) {
return Buffer . TYPED _ARRAY _SUPPORT
? 0x7fffffff
: 0x3fffffff
}
2018-06-28 17:35:20 +00:00
=== === =
} ) ( )
=== === =
* node . js errors - we only use some of these , add as needed .
* /
//'-1:UNKNOWN:unknown error',
//'0:OK:success',
//'1:EOF:end of file',
//'2:EADDRINFO:getaddrinfo error',
//'3:EACCES:permission denied',
//'4:EAGAIN:resource temporarily unavailable',
//'5:EADDRINUSE:address already in use',
//'6:EADDRNOTAVAIL:address not available',
//'7:EAFNOSUPPORT:address family not supported',
//'8:EALREADY:connection already in progress',
'9:EBADF:bad file descriptor' , '10:EBUSY:resource busy or locked' ,
//'11:ECONNABORTED:software caused connection abort',
//'12:ECONNREFUSED:connection refused',
//'13:ECONNRESET:connection reset by peer',
//'14:EDESTADDRREQ:destination address required',
//'15:EFAULT:bad address in system call argument',
//'16:EHOSTUNREACH:host is unreachable',
//'17:EINTR:interrupted system call',
'18:EINVAL:invalid argument' ,
//'19:EISCONN:socket is already connected',
//'20:EMFILE:too many open files',
//'21:EMSGSIZE:message too long',
//'22:ENETDOWN:network is down',
//'23:ENETUNREACH:network is unreachable',
//'24:ENFILE:file table overflow',
//'25:ENOBUFS:no buffer space available',
//'26:ENOMEM:not enough memory',
'27:ENOTDIR:not a directory' , '28:EISDIR:illegal operation on a directory' ,
//'29:ENONET:machine is not on the network',
// errno 30 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
//'31:ENOTCONN:socket is not connected',
//'32:ENOTSOCK:socket operation on non-socket',
//'33:ENOTSUP:operation not supported on socket',
'34:ENOENT:no such file or directory' ,
//'35:ENOSYS:function not implemented',
//'36:EPIPE:broken pipe',
//'37:EPROTO:protocol error',
//'38:EPROTONOSUPPORT:protocol not supported',
//'39:EPROTOTYPE:protocol wrong type for socket',
//'40:ETIMEDOUT:connection timed out',
//'41:ECHARSET:invalid Unicode character',
//'42:EAIFAMNOSUPPORT:address family for hostname not supported',
// errno 43 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
//'44:EAISERVICE:servname not supported for ai_socktype',
//'45:EAISOCKTYPE:ai_socktype not supported',
//'46:ESHUTDOWN:cannot send after transport endpoint shutdown',
'47:EEXIST:file already exists' ,
//'48:ESRCH:no such process',
//'49:ENAMETOOLONG:name too long',
//'50:EPERM:operation not permitted',
'51:ELOOP:too many symbolic links encountered' ,
//'52:EXDEV:cross-device link not permitted',
'53:ENOTEMPTY:directory not empty' ,
//'54:ENOSPC:no space left on device',
'55:EIO:i/o error' ,
//'56:EROFS:read-only file system',
//'57:ENODEV:no such device',
//'58:ESPIPE:invalid seek',
//'59:ECANCELED:operation canceled',
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-06-10 18:53:04 +00:00
/ * *
2018-06-28 17:35:20 +00:00
* Filer specific errors
2014-06-10 18:53:04 +00:00
* /
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
function Buffer ( arg ) {
if ( ! ( this instanceof Buffer ) ) {
// Avoid going through an ArgumentsAdaptorTrampoline in the common case.
if ( arguments . length > 1 ) return new Buffer ( arg , arguments [ 1 ] )
return new Buffer ( arg )
}
2018-05-29 18:03:59 +00:00
if ( ! Buffer . TYPED _ARRAY _SUPPORT ) {
this . length = 0
this . parent = undefined
}
2015-06-29 16:29:46 +00:00
// Common case.
if ( typeof arg === 'number' ) {
return fromNumber ( this , arg )
}
// Slightly less common case.
if ( typeof arg === 'string' ) {
return fromString ( this , arg , arguments . length > 1 ? arguments [ 1 ] : 'utf8' )
}
// Unusual.
return fromObject ( this , arg )
}
function fromNumber ( that , length ) {
that = allocate ( that , length < 0 ? 0 : checked ( length ) | 0 )
if ( ! Buffer . TYPED _ARRAY _SUPPORT ) {
for ( var i = 0 ; i < length ; i ++ ) {
that [ i ] = 0
2018-06-28 17:35:20 +00:00
=== === =
'1000:ENOTMOUNTED:not mounted' , '1001:EFILESYSTEMERROR:missing super node, use \'FORMAT\' flag to format filesystem.' , '1002:ENOATTR:attribute does not exist' ] . forEach ( function ( e ) {
e = e . split ( ':' ) ;
var errno = + e [ 0 ] ;
var errName = e [ 1 ] ;
var defaultMessage = e [ 2 ] ;
function FilerError ( msg , path ) {
Error . call ( this ) ;
this . name = errName ;
this . code = errName ;
this . errno = errno ;
this . message = msg || defaultMessage ;
if ( path ) {
this . path = path ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2015-06-29 16:29:46 +00:00
}
2018-06-28 17:35:20 +00:00
this . stack = new Error ( this . message ) . stack ;
2015-06-29 16:29:46 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
return that
}
function fromString ( that , string , encoding ) {
if ( typeof encoding !== 'string' || encoding === '' ) encoding = 'utf8'
// Assumption: byteLength() return value is always < kMaxLength.
var length = byteLength ( string , encoding ) | 0
that = allocate ( that , length )
that . write ( string , encoding )
return that
}
function fromObject ( that , object ) {
if ( Buffer . isBuffer ( object ) ) return fromBuffer ( that , object )
if ( isArray ( object ) ) return fromArray ( that , object )
if ( object == null ) {
2015-05-31 15:18:20 +00:00
throw new TypeError ( 'must start with number, buffer, array or string' )
2015-06-29 16:29:46 +00:00
}
2015-05-31 15:18:20 +00:00
2018-05-29 18:03:59 +00:00
if ( typeof ArrayBuffer !== 'undefined' ) {
if ( object . buffer instanceof ArrayBuffer ) {
return fromTypedArray ( that , object )
}
if ( object instanceof ArrayBuffer ) {
return fromArrayBuffer ( that , object )
}
2015-06-29 16:29:46 +00:00
}
if ( object . length ) return fromArrayLike ( that , object )
return fromJsonObject ( that , object )
}
function fromBuffer ( that , buffer ) {
var length = checked ( buffer . length ) | 0
that = allocate ( that , length )
buffer . copy ( that , 0 , 0 , length )
return that
}
2014-06-10 18:53:04 +00:00
2015-06-29 16:29:46 +00:00
function fromArray ( that , array ) {
var length = checked ( array . length ) | 0
that = allocate ( that , length )
for ( var i = 0 ; i < length ; i += 1 ) {
that [ i ] = array [ i ] & 255
}
return that
}
// Duplicate of fromArray() to keep fromArray() monomorphic.
function fromTypedArray ( that , array ) {
var length = checked ( array . length ) | 0
that = allocate ( that , length )
// Truncating the elements is probably not what people expect from typed
// arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior
// of the old Buffer constructor.
for ( var i = 0 ; i < length ; i += 1 ) {
that [ i ] = array [ i ] & 255
}
return that
}
2018-05-29 18:03:59 +00:00
function fromArrayBuffer ( that , array ) {
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
// Return an augmented `Uint8Array` instance, for best performance
array . byteLength
that = Buffer . _augment ( new Uint8Array ( array ) )
} else {
// Fallback: Return an object instance of the Buffer class
that = fromTypedArray ( that , new Uint8Array ( array ) )
}
return that
}
2015-06-29 16:29:46 +00:00
function fromArrayLike ( that , array ) {
var length = checked ( array . length ) | 0
that = allocate ( that , length )
for ( var i = 0 ; i < length ; i += 1 ) {
that [ i ] = array [ i ] & 255
}
return that
}
// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
// Returns a zero-length buffer for inputs that don't conform to the spec.
function fromJsonObject ( that , object ) {
var array
var length = 0
if ( object . type === 'Buffer' && isArray ( object . data ) ) {
array = object . data
length = checked ( array . length ) | 0
}
that = allocate ( that , length )
for ( var i = 0 ; i < length ; i += 1 ) {
that [ i ] = array [ i ] & 255
}
return that
}
2018-05-29 18:03:59 +00:00
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
Buffer . prototype . _ _proto _ _ = Uint8Array . prototype
Buffer . _ _proto _ _ = Uint8Array
} else {
// pre-set for values that may exist in the future
Buffer . prototype . length = undefined
Buffer . prototype . parent = undefined
}
2015-06-29 16:29:46 +00:00
function allocate ( that , length ) {
2015-05-31 15:18:20 +00:00
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
2015-06-29 16:29:46 +00:00
// Return an augmented `Uint8Array` instance, for best performance
that = Buffer . _augment ( new Uint8Array ( length ) )
2018-05-29 18:03:59 +00:00
that . _ _proto _ _ = Buffer . prototype
2014-06-10 18:53:04 +00:00
} else {
2015-06-29 16:29:46 +00:00
// Fallback: Return an object instance of the Buffer class
that . length = length
that . _isBuffer = true
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
var fromPool = length !== 0 && length <= Buffer . poolSize >>> 1
if ( fromPool ) that . parent = rootParent
return that
}
function checked ( length ) {
// Note: cannot use `length < kMaxLength` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
2018-05-29 18:03:59 +00:00
if ( length >= kMaxLength ( ) ) {
2015-06-29 16:29:46 +00:00
throw new RangeError ( 'Attempt to allocate Buffer larger than maximum ' +
2018-05-29 18:03:59 +00:00
'size: 0x' + kMaxLength ( ) . toString ( 16 ) + ' bytes' )
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
return length | 0
}
function SlowBuffer ( subject , encoding ) {
if ( ! ( this instanceof SlowBuffer ) ) return new SlowBuffer ( subject , encoding )
2014-06-10 18:53:04 +00:00
2015-06-29 16:29:46 +00:00
var buf = new Buffer ( subject , encoding )
delete buf . parent
2014-06-10 18:53:04 +00:00
return buf
}
2015-06-29 16:29:46 +00:00
Buffer . isBuffer = function isBuffer ( b ) {
2015-05-31 15:18:20 +00:00
return ! ! ( b != null && b . _isBuffer )
}
2015-06-29 16:29:46 +00:00
Buffer . compare = function compare ( a , b ) {
if ( ! Buffer . isBuffer ( a ) || ! Buffer . isBuffer ( b ) ) {
2015-05-31 15:18:20 +00:00
throw new TypeError ( 'Arguments must be Buffers' )
2015-06-29 16:29:46 +00:00
}
if ( a === b ) return 0
2015-05-31 15:18:20 +00:00
var x = a . length
var y = b . length
2015-06-29 16:29:46 +00:00
var i = 0
var len = Math . min ( x , y )
while ( i < len ) {
if ( a [ i ] !== b [ i ] ) break
++ i
}
2015-05-31 15:18:20 +00:00
if ( i !== len ) {
x = a [ i ]
y = b [ i ]
}
2015-06-29 16:29:46 +00:00
2015-05-31 15:18:20 +00:00
if ( x < y ) return - 1
if ( y < x ) return 1
return 0
}
2014-06-10 18:53:04 +00:00
2015-06-29 16:29:46 +00:00
Buffer . isEncoding = function isEncoding ( encoding ) {
2014-06-10 18:53:04 +00:00
switch ( String ( encoding ) . toLowerCase ( ) ) {
case 'hex' :
case 'utf8' :
case 'utf-8' :
case 'ascii' :
case 'binary' :
case 'base64' :
case 'raw' :
case 'ucs2' :
case 'ucs-2' :
case 'utf16le' :
case 'utf-16le' :
return true
default :
return false
2018-06-28 17:35:20 +00:00
=== === =
FilerError . prototype = Object . create ( Error . prototype ) ;
FilerError . prototype . constructor = FilerError ;
FilerError . prototype . toString = function ( ) {
var pathInfo = this . path ? ', \'' + this . path + '\'' : '' ;
return this . name + ': ' + this . message + pathInfo ;
} ;
// We expose the error as both Errors.EINVAL and Errors[18]
errors [ errName ] = errors [ errno ] = FilerError ;
} ) ;
module . exports = errors ;
} , { } ] , 29 : [ function ( require , module , exports ) {
'use strict'
exports . byteLength = byteLength
exports . toByteArray = toByteArray
exports . fromByteArray = fromByteArray
var lookup = [ ]
var revLookup = [ ]
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
for ( var i = 0 , len = code . length ; i < len ; ++ i ) {
lookup [ i ] = code [ i ]
revLookup [ code . charCodeAt ( i ) ] = i
}
// Support decoding URL-safe base64 strings, as Node.js does.
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
revLookup [ '-' . charCodeAt ( 0 ) ] = 62
revLookup [ '_' . charCodeAt ( 0 ) ] = 63
function getLens ( b64 ) {
var len = b64 . length
if ( len % 4 > 0 ) {
throw new Error ( 'Invalid string. Length must be a multiple of 4' )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
// Trim off extra bytes after placeholder bytes are found
// See: https://github.com/beatgammit/base64-js/issues/42
var validLen = b64 . indexOf ( '=' )
if ( validLen === - 1 ) validLen = len
var placeHoldersLen = validLen === len
? 0
: 4 - ( validLen % 4 )
return [ validLen , placeHoldersLen ]
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
Buffer . concat = function concat ( list , length ) {
if ( ! isArray ( list ) ) throw new TypeError ( 'list argument must be an Array of Buffers.' )
2014-06-10 18:53:04 +00:00
if ( list . length === 0 ) {
return new Buffer ( 0 )
}
var i
2015-06-29 16:29:46 +00:00
if ( length === undefined ) {
length = 0
2014-06-10 18:53:04 +00:00
for ( i = 0 ; i < list . length ; i ++ ) {
2015-06-29 16:29:46 +00:00
length += list [ i ] . length
2014-06-10 18:53:04 +00:00
}
}
2015-06-29 16:29:46 +00:00
var buf = new Buffer ( length )
2014-06-10 18:53:04 +00:00
var pos = 0
for ( i = 0 ; i < list . length ; i ++ ) {
var item = list [ i ]
item . copy ( buf , pos )
pos += item . length
}
return buf
}
2015-06-29 16:29:46 +00:00
function byteLength ( string , encoding ) {
2018-05-29 18:03:59 +00:00
if ( typeof string !== 'string' ) string = '' + string
2015-06-29 16:29:46 +00:00
2018-05-29 18:03:59 +00:00
var len = string . length
if ( len === 0 ) return 0
2015-06-29 16:29:46 +00:00
2018-05-29 18:03:59 +00:00
// Use a for loop to avoid recursion
var loweredCase = false
for ( ; ; ) {
switch ( encoding ) {
case 'ascii' :
case 'binary' :
// Deprecated
case 'raw' :
case 'raws' :
return len
case 'utf8' :
case 'utf-8' :
return utf8ToBytes ( string ) . length
case 'ucs2' :
case 'ucs-2' :
case 'utf16le' :
case 'utf-16le' :
return len * 2
case 'hex' :
return len >>> 1
case 'base64' :
return base64ToBytes ( string ) . length
default :
if ( loweredCase ) return utf8ToBytes ( string ) . length // assume utf8
encoding = ( '' + encoding ) . toLowerCase ( )
loweredCase = true
}
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
// base64 is 4/3 + up to two characters of the original data
function byteLength ( b64 ) {
var lens = getLens ( b64 )
var validLen = lens [ 0 ]
var placeHoldersLen = lens [ 1 ]
return ( ( validLen + placeHoldersLen ) * 3 / 4 ) - placeHoldersLen
}
function _byteLength ( b64 , validLen , placeHoldersLen ) {
return ( ( validLen + placeHoldersLen ) * 3 / 4 ) - placeHoldersLen
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2015-05-31 15:18:20 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . byteLength = byteLength
2015-05-31 15:18:20 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
function slowToString ( encoding , start , end ) {
2018-06-28 17:35:20 +00:00
=== === =
<< << << < HEAD
// pre-set for values that may exist in the future
Buffer . prototype . length = undefined
Buffer . prototype . parent = undefined
// toString(encoding, start=0, end=buffer.length)
Buffer . prototype . toString = function toString ( encoding , start , end ) {
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2015-05-31 15:18:20 +00:00
var loweredCase = false
2015-06-29 16:29:46 +00:00
start = start | 0
end = end === undefined || end === Infinity ? this . length : end | 0
2015-05-31 15:18:20 +00:00
if ( ! encoding ) encoding = 'utf8'
if ( start < 0 ) start = 0
if ( end > this . length ) end = this . length
if ( end <= start ) return ''
while ( true ) {
switch ( encoding ) {
case 'hex' :
return hexSlice ( this , start , end )
case 'utf8' :
case 'utf-8' :
return utf8Slice ( this , start , end )
case 'ascii' :
return asciiSlice ( this , start , end )
case 'binary' :
return binarySlice ( this , start , end )
case 'base64' :
return base64Slice ( this , start , end )
case 'ucs2' :
case 'ucs-2' :
case 'utf16le' :
case 'utf-16le' :
return utf16leSlice ( this , start , end )
default :
2015-06-29 16:29:46 +00:00
if ( loweredCase ) throw new TypeError ( 'Unknown encoding: ' + encoding )
2015-05-31 15:18:20 +00:00
encoding = ( encoding + '' ) . toLowerCase ( )
loweredCase = true
}
2018-06-28 17:35:20 +00:00
=== === =
function toByteArray ( b64 ) {
var tmp
var lens = getLens ( b64 )
var validLen = lens [ 0 ]
var placeHoldersLen = lens [ 1 ]
var arr = new Arr ( _byteLength ( b64 , validLen , placeHoldersLen ) )
var curByte = 0
// if there are placeholders, only get up to the last complete 4 chars
var len = placeHoldersLen > 0
? validLen - 4
: validLen
for ( var i = 0 ; i < len ; i += 4 ) {
tmp =
( revLookup [ b64 . charCodeAt ( i ) ] << 18 ) |
( revLookup [ b64 . charCodeAt ( i + 1 ) ] << 12 ) |
( revLookup [ b64 . charCodeAt ( i + 2 ) ] << 6 ) |
revLookup [ b64 . charCodeAt ( i + 3 ) ]
arr [ curByte ++ ] = ( tmp >> 16 ) & 0xFF
arr [ curByte ++ ] = ( tmp >> 8 ) & 0xFF
arr [ curByte ++ ] = tmp & 0xFF
}
if ( placeHoldersLen === 2 ) {
tmp =
( revLookup [ b64 . charCodeAt ( i ) ] << 2 ) |
( revLookup [ b64 . charCodeAt ( i + 1 ) ] >> 4 )
arr [ curByte ++ ] = tmp & 0xFF
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-06-10 18:53:04 +00:00
}
2015-05-31 15:18:20 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
Buffer . prototype . toString = function toString ( ) {
var length = this . length | 0
if ( length === 0 ) return ''
if ( arguments . length === 0 ) return utf8Slice ( this , 0 , length )
return slowToString . apply ( this , arguments )
}
2018-06-28 17:35:20 +00:00
=== === =
<< << << < HEAD
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2015-06-29 16:29:46 +00:00
Buffer . prototype . equals = function equals ( b ) {
if ( ! Buffer . isBuffer ( b ) ) throw new TypeError ( 'Argument must be a Buffer' )
if ( this === b ) return true
2015-05-31 15:18:20 +00:00
return Buffer . compare ( this , b ) === 0
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . inspect = function inspect ( ) {
2015-05-31 15:18:20 +00:00
var str = ''
var max = exports . INSPECT _MAX _BYTES
if ( this . length > 0 ) {
str = this . toString ( 'hex' , 0 , max ) . match ( /.{2}/g ) . join ( ' ' )
2015-06-29 16:29:46 +00:00
if ( this . length > max ) str += ' ... '
2014-06-10 18:53:04 +00:00
}
2015-05-31 15:18:20 +00:00
return '<Buffer ' + str + '>'
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . compare = function compare ( b ) {
2015-05-31 15:18:20 +00:00
if ( ! Buffer . isBuffer ( b ) ) throw new TypeError ( 'Argument must be a Buffer' )
2015-06-29 16:29:46 +00:00
if ( this === b ) return 0
2015-05-31 15:18:20 +00:00
return Buffer . compare ( this , b )
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . indexOf = function indexOf ( val , byteOffset ) {
if ( byteOffset > 0x7fffffff ) byteOffset = 0x7fffffff
else if ( byteOffset < - 0x80000000 ) byteOffset = - 0x80000000
byteOffset >>= 0
if ( this . length === 0 ) return - 1
if ( byteOffset >= this . length ) return - 1
// Negative offsets start from the end of the buffer
if ( byteOffset < 0 ) byteOffset = Math . max ( this . length + byteOffset , 0 )
if ( typeof val === 'string' ) {
if ( val . length === 0 ) return - 1 // special case: looking for empty string always fails
return String . prototype . indexOf . call ( this , val , byteOffset )
}
if ( Buffer . isBuffer ( val ) ) {
return arrayIndexOf ( this , val , byteOffset )
}
if ( typeof val === 'number' ) {
if ( Buffer . TYPED _ARRAY _SUPPORT && Uint8Array . prototype . indexOf === 'function' ) {
return Uint8Array . prototype . indexOf . call ( this , val , byteOffset )
}
return arrayIndexOf ( this , [ val ] , byteOffset )
}
function arrayIndexOf ( arr , val , byteOffset ) {
var foundIndex = - 1
for ( var i = 0 ; byteOffset + i < arr . length ; i ++ ) {
if ( arr [ byteOffset + i ] === val [ foundIndex === - 1 ? 0 : i - foundIndex ] ) {
if ( foundIndex === - 1 ) foundIndex = i
if ( i - foundIndex + 1 === val . length ) return byteOffset + foundIndex
} else {
foundIndex = - 1
}
}
return - 1
}
throw new TypeError ( 'val must be string, number or Buffer' )
}
2018-05-29 18:03:59 +00:00
// `get` is deprecated
2015-06-29 16:29:46 +00:00
Buffer . prototype . get = function get ( offset ) {
2015-05-31 15:18:20 +00:00
console . log ( '.get() is deprecated. Access using array indexes instead.' )
return this . readUInt8 ( offset )
}
2018-05-29 18:03:59 +00:00
// `set` is deprecated
2015-06-29 16:29:46 +00:00
Buffer . prototype . set = function set ( v , offset ) {
2015-05-31 15:18:20 +00:00
console . log ( '.set() is deprecated. Access using array indexes instead.' )
return this . writeUInt8 ( v , offset )
}
2018-06-28 17:35:20 +00:00
=== === =
if ( placeHoldersLen === 1 ) {
tmp =
( revLookup [ b64 . charCodeAt ( i ) ] << 10 ) |
( revLookup [ b64 . charCodeAt ( i + 1 ) ] << 4 ) |
( revLookup [ b64 . charCodeAt ( i + 2 ) ] >> 2 )
arr [ curByte ++ ] = ( tmp >> 8 ) & 0xFF
arr [ curByte ++ ] = tmp & 0xFF
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
return arr
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
function tripletToBase64 ( num ) {
return lookup [ num >> 18 & 0x3F ] +
lookup [ num >> 12 & 0x3F ] +
lookup [ num >> 6 & 0x3F ] +
lookup [ num & 0x3F ]
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
function encodeChunk ( uint8 , start , end ) {
var tmp
var output = [ ]
for ( var i = start ; i < end ; i += 3 ) {
tmp =
( ( uint8 [ i ] << 16 ) & 0xFF0000 ) +
( ( uint8 [ i + 1 ] << 8 ) & 0xFF00 ) +
( uint8 [ i + 2 ] & 0xFF )
output . push ( tripletToBase64 ( tmp ) )
}
return output . join ( '' )
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
function fromByteArray ( uint8 ) {
var tmp
var len = uint8 . length
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
var parts = [ ]
var maxChunkLength = 16383 // must be multiple of 3
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
// go through the array every three bytes, we'll deal with trailing stuff later
for ( var i = 0 , len2 = len - extraBytes ; i < len2 ; i += maxChunkLength ) {
parts . push ( encodeChunk (
uint8 , i , ( i + maxChunkLength ) > len2 ? len2 : ( i + maxChunkLength )
) )
}
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
// pad the end with zeros, but make sure to not forget the extra bytes
if ( extraBytes === 1 ) {
tmp = uint8 [ len - 1 ]
parts . push (
lookup [ tmp >> 2 ] +
lookup [ ( tmp << 4 ) & 0x3F ] +
'=='
)
} else if ( extraBytes === 2 ) {
tmp = ( uint8 [ len - 2 ] << 8 ) + uint8 [ len - 1 ]
parts . push (
lookup [ tmp >> 10 ] +
lookup [ ( tmp >> 4 ) & 0x3F ] +
lookup [ ( tmp << 2 ) & 0x3F ] +
'='
)
}
return parts . join ( '' )
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
} , { } ] , 30 : [ function ( require , module , exports ) {
exports . read = function ( buffer , offset , isLE , mLen , nBytes ) {
var e , m
var eLen = ( nBytes * 8 ) - mLen - 1
var eMax = ( 1 << eLen ) - 1
var eBias = eMax >> 1
var nBits = - 7
var i = isLE ? ( nBytes - 1 ) : 0
var d = isLE ? - 1 : 1
var s = buffer [ offset + i ]
i += d
e = s & ( ( 1 << ( - nBits ) ) - 1 )
s >>= ( - nBits )
nBits += eLen
for ( ; nBits > 0 ; e = ( e * 256 ) + buffer [ offset + i ] , i += d , nBits -= 8 ) { }
m = e & ( ( 1 << ( - nBits ) ) - 1 )
e >>= ( - nBits )
nBits += mLen
for ( ; nBits > 0 ; m = ( m * 256 ) + buffer [ offset + i ] , i += d , nBits -= 8 ) { }
if ( e === 0 ) {
e = 1 - eBias
} else if ( e === eMax ) {
return m ? NaN : ( ( s ? - 1 : 1 ) * Infinity )
} else {
m = m + Math . pow ( 2 , mLen )
e = e - eBias
}
return ( s ? - 1 : 1 ) * m * Math . pow ( 2 , e - mLen )
}
exports . write = function ( buffer , value , offset , isLE , mLen , nBytes ) {
var e , m , c
var eLen = ( nBytes * 8 ) - mLen - 1
var eMax = ( 1 << eLen ) - 1
var eBias = eMax >> 1
var rt = ( mLen === 23 ? Math . pow ( 2 , - 24 ) - Math . pow ( 2 , - 77 ) : 0 )
var i = isLE ? 0 : ( nBytes - 1 )
var d = isLE ? 1 : - 1
var s = value < 0 || ( value === 0 && 1 / value < 0 ) ? 1 : 0
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
value = Math . abs ( value )
if ( isNaN ( value ) || value === Infinity ) {
m = isNaN ( value ) ? 1 : 0
e = eMax
} else {
e = Math . floor ( Math . log ( value ) / Math . LN2 )
if ( value * ( c = Math . pow ( 2 , - e ) ) < 1 ) {
e --
c *= 2
}
if ( e + eBias >= 1 ) {
value += rt / c
} else {
value += rt * Math . pow ( 2 , 1 - eBias )
}
if ( value * c >= 2 ) {
e ++
c /= 2
}
if ( e + eBias >= eMax ) {
m = 0
e = eMax
} else if ( e + eBias >= 1 ) {
m = ( ( value * c ) - 1 ) * Math . pow ( 2 , mLen )
e = e + eBias
} else {
m = value * Math . pow ( 2 , eBias - 1 ) * Math . pow ( 2 , mLen )
e = 0
}
}
<< << << < HEAD
// must be an even number of digits
var strLen = string . length
if ( strLen % 2 !== 0 ) throw new Error ( 'Invalid hex string' )
if ( length > strLen / 2 ) {
length = strLen / 2
}
for ( var i = 0 ; i < length ; i ++ ) {
var parsed = parseInt ( string . substr ( i * 2 , 2 ) , 16 )
if ( isNaN ( parsed ) ) throw new Error ( 'Invalid hex string' )
buf [ offset + i ] = parsed
}
return i
}
function utf8Write ( buf , string , offset , length ) {
return blitBuffer ( utf8ToBytes ( string , buf . length - offset ) , buf , offset , length )
}
function asciiWrite ( buf , string , offset , length ) {
return blitBuffer ( asciiToBytes ( string ) , buf , offset , length )
}
=== === =
for ( ; mLen >= 8 ; buffer [ offset + i ] = m & 0xff , i += d , m /= 256 , mLen -= 8 ) { }
e = ( e << mLen ) | m
eLen += mLen
for ( ; eLen > 0 ; buffer [ offset + i ] = e & 0xff , i += d , e /= 256 , eLen -= 8 ) { }
buffer [ offset + i - d ] |= s * 128
}
} , { } ] , 31 : [ function ( require , module , exports ) {
var toString = { } . toString ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
module . exports = Array . isArray || function ( arr ) {
return toString . call ( arr ) == '[object Array]' ;
} ;
<< << << < HEAD
function base64Write ( buf , string , offset , length ) {
return blitBuffer ( base64ToBytes ( string ) , buf , offset , length )
}
function ucs2Write ( buf , string , offset , length ) {
return blitBuffer ( utf16leToBytes ( string , buf . length - offset ) , buf , offset , length )
}
Buffer . prototype . write = function write ( string , offset , length , encoding ) {
// Buffer#write(string)
if ( offset === undefined ) {
encoding = 'utf8'
2015-06-29 16:29:46 +00:00
length = this . length
offset = 0
// Buffer#write(string, encoding)
} else if ( length === undefined && typeof offset === 'string' ) {
encoding = offset
length = this . length
offset = 0
// Buffer#write(string, offset[, length][, encoding])
} else if ( isFinite ( offset ) ) {
offset = offset | 0
if ( isFinite ( length ) ) {
length = length | 0
if ( encoding === undefined ) encoding = 'utf8'
} else {
2014-06-10 18:53:04 +00:00
encoding = length
length = undefined
}
2015-06-29 16:29:46 +00:00
// legacy write(string, encoding, offset, length) - remove in v0.13
} else {
2014-06-10 18:53:04 +00:00
var swap = encoding
encoding = offset
2015-06-29 16:29:46 +00:00
offset = length | 0
2014-06-10 18:53:04 +00:00
length = swap
}
var remaining = this . length - offset
2015-06-29 16:29:46 +00:00
if ( length === undefined || length > remaining ) length = remaining
if ( ( string . length > 0 && ( length < 0 || offset < 0 ) ) || offset > this . length ) {
throw new RangeError ( 'attempt to write outside buffer bounds' )
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
if ( ! encoding ) encoding = 'utf8'
var loweredCase = false
for ( ; ; ) {
switch ( encoding ) {
case 'hex' :
return hexWrite ( this , string , offset , length )
case 'utf8' :
case 'utf-8' :
return utf8Write ( this , string , offset , length )
case 'ascii' :
return asciiWrite ( this , string , offset , length )
case 'binary' :
return binaryWrite ( this , string , offset , length )
case 'base64' :
// Warning: maxLength not taken into account in base64Write
return base64Write ( this , string , offset , length )
case 'ucs2' :
case 'ucs-2' :
case 'utf16le' :
case 'utf-16le' :
return ucs2Write ( this , string , offset , length )
default :
if ( loweredCase ) throw new TypeError ( 'Unknown encoding: ' + encoding )
encoding = ( '' + encoding ) . toLowerCase ( )
loweredCase = true
}
2014-06-10 18:53:04 +00:00
}
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . toJSON = function toJSON ( ) {
2014-06-10 18:53:04 +00:00
return {
type : 'Buffer' ,
data : Array . prototype . slice . call ( this . _arr || this , 0 )
2018-06-28 17:35:20 +00:00
=== === =
} , { } ] , 11 : [ function ( require , module , exports ) {
var global = arguments [ 3 ] ;
/ * !
* The buffer module from node . js , for the browser .
*
* @ author Feross Aboukhadijeh < feross @ feross . org > < http : //feross.org>
* @ license MIT
* /
/* eslint-disable no-proto */
'use strict'
var base64 = require ( 'base64-js' )
var ieee754 = require ( 'ieee754' )
var isArray = require ( 'isarray' )
exports . Buffer = Buffer
exports . SlowBuffer = SlowBuffer
exports . INSPECT _MAX _BYTES = 50
/ * *
* If ` Buffer.TYPED_ARRAY_SUPPORT ` :
* === true Use Uint8Array implementation ( fastest )
* === false Use Object implementation ( most compatible , even IE6 )
*
* Browsers that support typed arrays are IE 10 + , Firefox 4 + , Chrome 7 + , Safari 5.1 + ,
* Opera 11.6 + , iOS 4.2 + .
*
* Due to various browser bugs , sometimes the Object implementation will be used even
* when the browser supports typed arrays .
*
* Note :
*
* - Firefox 4 - 29 lacks support for adding new properties to ` Uint8Array ` instances ,
* See : https : //bugzilla.mozilla.org/show_bug.cgi?id=695438.
*
* - Chrome 9 - 10 is missing the ` TypedArray.prototype.subarray ` function .
*
* - IE10 has a broken ` TypedArray.prototype.subarray ` function which returns arrays of
* incorrect length in some situations .
* We detect these buggy browsers and set ` Buffer.TYPED_ARRAY_SUPPORT ` to ` false ` so they
* get the Object implementation , which is slower but behaves correctly .
* /
Buffer . TYPED _ARRAY _SUPPORT = global . TYPED _ARRAY _SUPPORT !== undefined
? global . TYPED _ARRAY _SUPPORT
: typedArraySupport ( )
/ *
* Export kMaxLength after typed array support is determined .
* /
exports . kMaxLength = kMaxLength ( )
function typedArraySupport ( ) {
try {
var arr = new Uint8Array ( 1 )
arr . _ _proto _ _ = { _ _proto _ _ : Uint8Array . prototype , foo : function ( ) { return 42 } }
return arr . foo ( ) === 42 && // typed array instances can be augmented
typeof arr . subarray === 'function' && // chrome 9-10 lack `subarray`
arr . subarray ( 1 , 1 ) . byteLength === 0 // ie10 has broken `subarray`
} catch ( e ) {
return false
}
}
function kMaxLength ( ) {
return Buffer . TYPED _ARRAY _SUPPORT
? 0x7fffffff
: 0x3fffffff
}
function createBuffer ( that , length ) {
if ( kMaxLength ( ) < length ) {
throw new RangeError ( 'Invalid typed array length' )
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
// Return an augmented `Uint8Array` instance, for best performance
that = new Uint8Array ( length )
that . _ _proto _ _ = Buffer . prototype
} else {
// Fallback: Return an object instance of the Buffer class
if ( that === null ) {
that = new Buffer ( length )
}
that . length = length
}
return that
}
/ * *
* The Buffer constructor returns instances of ` Uint8Array ` that have their
* prototype changed to ` Buffer.prototype ` . Furthermore , ` Buffer ` is a subclass of
* ` Uint8Array ` , so the returned instances will have all the node ` Buffer ` methods
* and the ` Uint8Array ` methods . Square bracket notation works as expected -- it
* returns a single octet .
*
* The ` Uint8Array ` prototype remains unmodified .
* /
function Buffer ( arg , encodingOrOffset , length ) {
if ( ! Buffer . TYPED _ARRAY _SUPPORT && ! ( this instanceof Buffer ) ) {
return new Buffer ( arg , encodingOrOffset , length )
}
// Common case.
if ( typeof arg === 'number' ) {
if ( typeof encodingOrOffset === 'string' ) {
throw new Error (
'If encoding is specified then the first argument must be a string'
)
}
return allocUnsafe ( this , arg )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
return from ( this , arg , encodingOrOffset , length )
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-06-10 18:53:04 +00:00
function base64Slice ( buf , start , end ) {
if ( start === 0 && end === buf . length ) {
return base64 . fromByteArray ( buf )
} else {
return base64 . fromByteArray ( buf . slice ( start , end ) )
2018-06-28 17:35:20 +00:00
=== === =
Buffer . poolSize = 8192 // not used by this implementation
// TODO: Legacy, not needed anymore. Remove in next major version.
Buffer . _augment = function ( arr ) {
arr . _ _proto _ _ = Buffer . prototype
return arr
}
function from ( that , value , encodingOrOffset , length ) {
if ( typeof value === 'number' ) {
throw new TypeError ( '"value" argument must not be a number' )
}
if ( typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer ) {
return fromArrayBuffer ( that , value , encodingOrOffset , length )
}
if ( typeof value === 'string' ) {
return fromString ( that , value , encodingOrOffset )
}
return fromObject ( that , value )
}
/ * *
* Functionally equivalent to Buffer ( arg , encoding ) but throws a TypeError
* if value is a number .
* Buffer . from ( str [ , encoding ] )
* Buffer . from ( array )
* Buffer . from ( buffer )
* Buffer . from ( arrayBuffer [ , byteOffset [ , length ] ] )
* * /
Buffer . from = function ( value , encodingOrOffset , length ) {
return from ( null , value , encodingOrOffset , length )
}
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
Buffer . prototype . _ _proto _ _ = Uint8Array . prototype
Buffer . _ _proto _ _ = Uint8Array
if ( typeof Symbol !== 'undefined' && Symbol . species &&
Buffer [ Symbol . species ] === Buffer ) {
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
Object . defineProperty ( Buffer , Symbol . species , {
value : null ,
configurable : true
} )
2014-06-10 18:53:04 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-06-10 18:53:04 +00:00
function utf8Slice ( buf , start , end ) {
end = Math . min ( buf . length , end )
2018-05-29 18:03:59 +00:00
var res = [ ]
var i = start
while ( i < end ) {
var firstByte = buf [ i ]
var codePoint = null
var bytesPerSequence = ( firstByte > 0xEF ) ? 4
: ( firstByte > 0xDF ) ? 3
: ( firstByte > 0xBF ) ? 2
: 1
if ( i + bytesPerSequence <= end ) {
var secondByte , thirdByte , fourthByte , tempCodePoint
switch ( bytesPerSequence ) {
case 1 :
if ( firstByte < 0x80 ) {
codePoint = firstByte
}
break
case 2 :
secondByte = buf [ i + 1 ]
if ( ( secondByte & 0xC0 ) === 0x80 ) {
tempCodePoint = ( firstByte & 0x1F ) << 0x6 | ( secondByte & 0x3F )
if ( tempCodePoint > 0x7F ) {
codePoint = tempCodePoint
}
}
break
case 3 :
secondByte = buf [ i + 1 ]
thirdByte = buf [ i + 2 ]
if ( ( secondByte & 0xC0 ) === 0x80 && ( thirdByte & 0xC0 ) === 0x80 ) {
tempCodePoint = ( firstByte & 0xF ) << 0xC | ( secondByte & 0x3F ) << 0x6 | ( thirdByte & 0x3F )
if ( tempCodePoint > 0x7FF && ( tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF ) ) {
codePoint = tempCodePoint
}
}
break
case 4 :
secondByte = buf [ i + 1 ]
thirdByte = buf [ i + 2 ]
fourthByte = buf [ i + 3 ]
if ( ( secondByte & 0xC0 ) === 0x80 && ( thirdByte & 0xC0 ) === 0x80 && ( fourthByte & 0xC0 ) === 0x80 ) {
tempCodePoint = ( firstByte & 0xF ) << 0x12 | ( secondByte & 0x3F ) << 0xC | ( thirdByte & 0x3F ) << 0x6 | ( fourthByte & 0x3F )
if ( tempCodePoint > 0xFFFF && tempCodePoint < 0x110000 ) {
codePoint = tempCodePoint
}
}
}
}
2014-06-10 18:53:04 +00:00
2018-05-29 18:03:59 +00:00
if ( codePoint === null ) {
// we did not generate a valid codePoint so insert a
// replacement char (U+FFFD) and advance only 1 byte
codePoint = 0xFFFD
bytesPerSequence = 1
} else if ( codePoint > 0xFFFF ) {
// encode to utf16 (surrogate pair dance)
codePoint -= 0x10000
res . push ( codePoint >>> 10 & 0x3FF | 0xD800 )
codePoint = 0xDC00 | codePoint & 0x3FF
2018-06-28 17:35:20 +00:00
=== === =
function assertSize ( size ) {
if ( typeof size !== 'number' ) {
throw new TypeError ( '"size" argument must be a number' )
} else if ( size < 0 ) {
throw new RangeError ( '"size" argument must not be negative' )
}
}
function alloc ( that , size , fill , encoding ) {
assertSize ( size )
if ( size <= 0 ) {
return createBuffer ( that , size )
}
if ( fill !== undefined ) {
// Only pay attention to encoding if it's a string. This
// prevents accidentally sending in a number that would
// be interpretted as a start offset.
return typeof encoding === 'string'
? createBuffer ( that , size ) . fill ( fill , encoding )
: createBuffer ( that , size ) . fill ( fill )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
return createBuffer ( that , size )
}
/ * *
* Creates a new filled Buffer instance .
* alloc ( size [ , fill [ , encoding ] ] )
* * /
Buffer . alloc = function ( size , fill , encoding ) {
return alloc ( null , size , fill , encoding )
}
function allocUnsafe ( that , size ) {
assertSize ( size )
that = createBuffer ( that , size < 0 ? 0 : checked ( size ) | 0 )
if ( ! Buffer . TYPED _ARRAY _SUPPORT ) {
for ( var i = 0 ; i < size ; ++ i ) {
that [ i ] = 0
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-06-10 18:53:04 +00:00
}
2018-05-29 18:03:59 +00:00
res . push ( codePoint )
i += bytesPerSequence
}
return decodeCodePointsArray ( res )
}
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
// the lowest limit is Chrome, with 0x10000 args.
// We go 1 magnitude less, for safety
var MAX _ARGUMENTS _LENGTH = 0x1000
function decodeCodePointsArray ( codePoints ) {
var len = codePoints . length
if ( len <= MAX _ARGUMENTS _LENGTH ) {
return String . fromCharCode . apply ( String , codePoints ) // avoid extra slice()
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
return that
}
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
// Decode in chunks to avoid "call stack size exceeded".
var res = ''
var i = 0
while ( i < len ) {
res += String . fromCharCode . apply (
String ,
codePoints . slice ( i , i += MAX _ARGUMENTS _LENGTH )
)
}
return res
2018-06-28 17:35:20 +00:00
=== === =
/ * *
* Equivalent to Buffer ( num ) , by default creates a non - zero - filled Buffer instance .
* * /
Buffer . allocUnsafe = function ( size ) {
return allocUnsafe ( null , size )
}
/ * *
* Equivalent to SlowBuffer ( num ) , by default creates a non - zero - filled Buffer instance .
* /
Buffer . allocUnsafeSlow = function ( size ) {
return allocUnsafe ( null , size )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-06-10 18:53:04 +00:00
function asciiSlice ( buf , start , end ) {
var ret = ''
end = Math . min ( buf . length , end )
for ( var i = start ; i < end ; i ++ ) {
2015-06-29 16:29:46 +00:00
ret += String . fromCharCode ( buf [ i ] & 0x7F )
2018-06-28 17:35:20 +00:00
=== === =
function fromString ( that , string , encoding ) {
if ( typeof encoding !== 'string' || encoding === '' ) {
encoding = 'utf8'
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-06-10 18:53:04 +00:00
function binarySlice ( buf , start , end ) {
2015-06-29 16:29:46 +00:00
var ret = ''
end = Math . min ( buf . length , end )
for ( var i = start ; i < end ; i ++ ) {
ret += String . fromCharCode ( buf [ i ] )
}
return ret
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
if ( ! Buffer . isEncoding ( encoding ) ) {
throw new TypeError ( '"encoding" must be a valid string encoding' )
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
var length = byteLength ( string , encoding ) | 0
that = createBuffer ( that , length )
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
var actual = that . write ( string , encoding )
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
if ( actual !== length ) {
// Writing a hex string, for example, that contains invalid characters will
// cause everything after the first invalid character to be ignored. (e.g.
// 'abxxcd' will be treated as 'ab')
that = that . slice ( 0 , actual )
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
return that
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
function fromArrayLike ( that , array ) {
var length = array . length < 0 ? 0 : checked ( array . length ) | 0
that = createBuffer ( that , length )
for ( var i = 0 ; i < length ; i += 1 ) {
that [ i ] = array [ i ] & 255
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
return that
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
Buffer . prototype . slice = function slice ( start , end ) {
2014-06-10 18:53:04 +00:00
var len = this . length
2015-05-31 15:18:20 +00:00
start = ~ ~ start
end = end === undefined ? len : ~ ~ end
2014-06-10 18:53:04 +00:00
2015-05-31 15:18:20 +00:00
if ( start < 0 ) {
2015-06-29 16:29:46 +00:00
start += len
if ( start < 0 ) start = 0
2015-05-31 15:18:20 +00:00
} else if ( start > len ) {
start = len
}
if ( end < 0 ) {
end += len
2015-06-29 16:29:46 +00:00
if ( end < 0 ) end = 0
2015-05-31 15:18:20 +00:00
} else if ( end > len ) {
end = len
}
2015-06-29 16:29:46 +00:00
if ( end < start ) end = start
2015-05-31 15:18:20 +00:00
2015-06-29 16:29:46 +00:00
var newBuf
2015-05-31 15:18:20 +00:00
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
2015-06-29 16:29:46 +00:00
newBuf = Buffer . _augment ( this . subarray ( start , end ) )
2014-06-10 18:53:04 +00:00
} else {
var sliceLen = end - start
2015-06-29 16:29:46 +00:00
newBuf = new Buffer ( sliceLen , undefined )
2014-06-10 18:53:04 +00:00
for ( var i = 0 ; i < sliceLen ; i ++ ) {
newBuf [ i ] = this [ i + start ]
}
}
2015-06-29 16:29:46 +00:00
if ( newBuf . length ) newBuf . parent = this . parent || this
return newBuf
2014-06-10 18:53:04 +00:00
}
2015-05-31 15:18:20 +00:00
/ *
* Need to make sure that buffer isn ' t trying to write out of bounds .
* /
function checkOffset ( offset , ext , length ) {
2015-06-29 16:29:46 +00:00
if ( ( offset % 1 ) !== 0 || offset < 0 ) throw new RangeError ( 'offset is not uint' )
if ( offset + ext > length ) throw new RangeError ( 'Trying to access beyond buffer length' )
}
Buffer . prototype . readUIntLE = function readUIntLE ( offset , byteLength , noAssert ) {
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) checkOffset ( offset , byteLength , this . length )
var val = this [ offset ]
var mul = 1
var i = 0
while ( ++ i < byteLength && ( mul *= 0x100 ) ) {
val += this [ offset + i ] * mul
}
return val
}
Buffer . prototype . readUIntBE = function readUIntBE ( offset , byteLength , noAssert ) {
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) {
checkOffset ( offset , byteLength , this . length )
}
var val = this [ offset + -- byteLength ]
var mul = 1
while ( byteLength > 0 && ( mul *= 0x100 ) ) {
val += this [ offset + -- byteLength ] * mul
}
return val
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readUInt8 = function readUInt8 ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 1 , this . length )
2014-06-10 18:53:04 +00:00
return this [ offset ]
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readUInt16LE = function readUInt16LE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 2 , this . length )
2015-05-31 15:18:20 +00:00
return this [ offset ] | ( this [ offset + 1 ] << 8 )
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readUInt16BE = function readUInt16BE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 2 , this . length )
2015-05-31 15:18:20 +00:00
return ( this [ offset ] << 8 ) | this [ offset + 1 ]
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readUInt32LE = function readUInt32LE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
2014-06-10 18:53:04 +00:00
2015-05-31 15:18:20 +00:00
return ( ( this [ offset ] ) |
( this [ offset + 1 ] << 8 ) |
( this [ offset + 2 ] << 16 ) ) +
( this [ offset + 3 ] * 0x1000000 )
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readUInt32BE = function readUInt32BE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
2014-06-10 18:53:04 +00:00
2015-05-31 15:18:20 +00:00
return ( this [ offset ] * 0x1000000 ) +
2015-06-29 16:29:46 +00:00
( ( this [ offset + 1 ] << 16 ) |
( this [ offset + 2 ] << 8 ) |
this [ offset + 3 ] )
}
Buffer . prototype . readIntLE = function readIntLE ( offset , byteLength , noAssert ) {
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) checkOffset ( offset , byteLength , this . length )
var val = this [ offset ]
var mul = 1
var i = 0
while ( ++ i < byteLength && ( mul *= 0x100 ) ) {
val += this [ offset + i ] * mul
2018-06-28 17:35:20 +00:00
=== === =
function fromArrayBuffer ( that , array , byteOffset , length ) {
array . byteLength // this throws if `array` is not a valid ArrayBuffer
if ( byteOffset < 0 || array . byteLength < byteOffset ) {
throw new RangeError ( '\'offset\' is out of bounds' )
}
if ( array . byteLength < byteOffset + ( length || 0 ) ) {
throw new RangeError ( '\'length\' is out of bounds' )
}
if ( byteOffset === undefined && length === undefined ) {
array = new Uint8Array ( array )
} else if ( length === undefined ) {
array = new Uint8Array ( array , byteOffset )
} else {
array = new Uint8Array ( array , byteOffset , length )
}
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
// Return an augmented `Uint8Array` instance, for best performance
that = array
that . _ _proto _ _ = Buffer . prototype
} else {
// Fallback: Return an object instance of the Buffer class
that = fromArrayLike ( that , array )
}
return that
}
function fromObject ( that , obj ) {
if ( Buffer . isBuffer ( obj ) ) {
var len = checked ( obj . length ) | 0
that = createBuffer ( that , len )
if ( that . length === 0 ) {
return that
}
obj . copy ( that , 0 , 0 , len )
return that
}
if ( obj ) {
if ( ( typeof ArrayBuffer !== 'undefined' &&
obj . buffer instanceof ArrayBuffer ) || 'length' in obj ) {
if ( typeof obj . length !== 'number' || isnan ( obj . length ) ) {
return createBuffer ( that , 0 )
}
return fromArrayLike ( that , obj )
}
if ( obj . type === 'Buffer' && isArray ( obj . data ) ) {
return fromArrayLike ( that , obj . data )
}
}
throw new TypeError ( 'First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.' )
}
function checked ( length ) {
// Note: cannot use `length < kMaxLength()` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
if ( length >= kMaxLength ( ) ) {
throw new RangeError ( 'Attempt to allocate Buffer larger than maximum ' +
'size: 0x' + kMaxLength ( ) . toString ( 16 ) + ' bytes' )
}
return length | 0
}
function SlowBuffer ( length ) {
if ( + length != length ) { // eslint-disable-line eqeqeq
length = 0
}
return Buffer . alloc ( + length )
}
Buffer . isBuffer = function isBuffer ( b ) {
return ! ! ( b != null && b . _isBuffer )
}
Buffer . compare = function compare ( a , b ) {
if ( ! Buffer . isBuffer ( a ) || ! Buffer . isBuffer ( b ) ) {
throw new TypeError ( 'Arguments must be Buffers' )
}
if ( a === b ) return 0
var x = a . length
var y = b . length
for ( var i = 0 , len = Math . min ( x , y ) ; i < len ; ++ i ) {
if ( a [ i ] !== b [ i ] ) {
x = a [ i ]
y = b [ i ]
break
}
}
if ( x < y ) return - 1
if ( y < x ) return 1
return 0
}
Buffer . isEncoding = function isEncoding ( encoding ) {
switch ( String ( encoding ) . toLowerCase ( ) ) {
case 'hex' :
case 'utf8' :
case 'utf-8' :
case 'ascii' :
case 'latin1' :
case 'binary' :
case 'base64' :
case 'ucs2' :
case 'ucs-2' :
case 'utf16le' :
case 'utf-16le' :
return true
default :
return false
}
}
Buffer . concat = function concat ( list , length ) {
if ( ! isArray ( list ) ) {
throw new TypeError ( '"list" argument must be an Array of Buffers' )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2015-06-29 16:29:46 +00:00
}
mul *= 0x80
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
if ( val >= mul ) val -= Math . pow ( 2 , 8 * byteLength )
return val
}
Buffer . prototype . readIntBE = function readIntBE ( offset , byteLength , noAssert ) {
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) checkOffset ( offset , byteLength , this . length )
var i = byteLength
var mul = 1
var val = this [ offset + -- i ]
while ( i > 0 && ( mul *= 0x100 ) ) {
val += this [ offset + -- i ] * mul
2018-06-28 17:35:20 +00:00
=== === =
if ( list . length === 0 ) {
return Buffer . alloc ( 0 )
}
var i
if ( length === undefined ) {
length = 0
for ( i = 0 ; i < list . length ; ++ i ) {
length += list [ i ] . length
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2015-06-29 16:29:46 +00:00
}
mul *= 0x80
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
if ( val >= mul ) val -= Math . pow ( 2 , 8 * byteLength )
return val
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readInt8 = function readInt8 ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 1 , this . length )
if ( ! ( this [ offset ] & 0x80 ) ) return ( this [ offset ] )
2015-05-31 15:18:20 +00:00
return ( ( 0xff - this [ offset ] + 1 ) * - 1 )
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readInt16LE = function readInt16LE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 2 , this . length )
2015-05-31 15:18:20 +00:00
var val = this [ offset ] | ( this [ offset + 1 ] << 8 )
return ( val & 0x8000 ) ? val | 0xFFFF0000 : val
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readInt16BE = function readInt16BE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 2 , this . length )
2015-05-31 15:18:20 +00:00
var val = this [ offset + 1 ] | ( this [ offset ] << 8 )
return ( val & 0x8000 ) ? val | 0xFFFF0000 : val
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readInt32LE = function readInt32LE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
2014-06-10 18:53:04 +00:00
2015-05-31 15:18:20 +00:00
return ( this [ offset ] ) |
2015-06-29 16:29:46 +00:00
( this [ offset + 1 ] << 8 ) |
( this [ offset + 2 ] << 16 ) |
( this [ offset + 3 ] << 24 )
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readInt32BE = function readInt32BE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
2014-06-10 18:53:04 +00:00
2015-05-31 15:18:20 +00:00
return ( this [ offset ] << 24 ) |
2015-06-29 16:29:46 +00:00
( this [ offset + 1 ] << 16 ) |
( this [ offset + 2 ] << 8 ) |
( this [ offset + 3 ] )
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readFloatLE = function readFloatLE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
2015-05-31 15:18:20 +00:00
return ieee754 . read ( this , offset , true , 23 , 4 )
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readFloatBE = function readFloatBE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
2015-05-31 15:18:20 +00:00
return ieee754 . read ( this , offset , false , 23 , 4 )
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readDoubleLE = function readDoubleLE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 8 , this . length )
2015-05-31 15:18:20 +00:00
return ieee754 . read ( this , offset , true , 52 , 8 )
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
Buffer . prototype . readDoubleBE = function readDoubleBE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 8 , this . length )
2015-05-31 15:18:20 +00:00
return ieee754 . read ( this , offset , false , 52 , 8 )
2014-06-10 18:53:04 +00:00
}
2015-05-31 15:18:20 +00:00
function checkInt ( buf , value , offset , ext , max , min ) {
if ( ! Buffer . isBuffer ( buf ) ) throw new TypeError ( 'buffer must be a Buffer instance' )
2015-06-29 16:29:46 +00:00
if ( value > max || value < min ) throw new RangeError ( 'value is out of bounds' )
if ( offset + ext > buf . length ) throw new RangeError ( 'index out of range' )
}
Buffer . prototype . writeUIntLE = function writeUIntLE ( value , offset , byteLength , noAssert ) {
value = + value
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) checkInt ( this , value , offset , byteLength , Math . pow ( 2 , 8 * byteLength ) , 0 )
var mul = 1
var i = 0
this [ offset ] = value & 0xFF
while ( ++ i < byteLength && ( mul *= 0x100 ) ) {
this [ offset + i ] = ( value / mul ) & 0xFF
}
return offset + byteLength
}
Buffer . prototype . writeUIntBE = function writeUIntBE ( value , offset , byteLength , noAssert ) {
value = + value
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) checkInt ( this , value , offset , byteLength , Math . pow ( 2 , 8 * byteLength ) , 0 )
var i = byteLength - 1
var mul = 1
this [ offset + i ] = value & 0xFF
while ( -- i >= 0 && ( mul *= 0x100 ) ) {
this [ offset + i ] = ( value / mul ) & 0xFF
}
return offset + byteLength
2015-05-31 15:18:20 +00:00
}
2014-06-10 18:53:04 +00:00
2015-06-29 16:29:46 +00:00
Buffer . prototype . writeUInt8 = function writeUInt8 ( value , offset , noAssert ) {
2015-05-31 15:18:20 +00:00
value = + value
2015-06-29 16:29:46 +00:00
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 1 , 0xff , 0 )
2015-05-31 15:18:20 +00:00
if ( ! Buffer . TYPED _ARRAY _SUPPORT ) value = Math . floor ( value )
2018-05-29 18:03:59 +00:00
this [ offset ] = ( value & 0xff )
2014-06-10 18:53:04 +00:00
return offset + 1
}
2015-05-31 15:18:20 +00:00
function objectWriteUInt16 ( buf , value , offset , littleEndian ) {
if ( value < 0 ) value = 0xffff + value + 1
for ( var i = 0 , j = Math . min ( buf . length - offset , 2 ) ; i < j ; i ++ ) {
buf [ offset + i ] = ( value & ( 0xff << ( 8 * ( littleEndian ? i : 1 - i ) ) ) ) >>>
( littleEndian ? i : 1 - i ) * 8
2018-06-28 17:35:20 +00:00
=== === =
var buffer = Buffer . allocUnsafe ( length )
var pos = 0
for ( i = 0 ; i < list . length ; ++ i ) {
var buf = list [ i ]
if ( ! Buffer . isBuffer ( buf ) ) {
throw new TypeError ( '"list" argument must be an Array of Buffers' )
}
buf . copy ( buffer , pos )
pos += buf . length
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
return buffer
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
function byteLength ( string , encoding ) {
if ( Buffer . isBuffer ( string ) ) {
return string . length
2015-06-29 16:29:46 +00:00
}
2018-06-28 17:35:20 +00:00
if ( typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer . isView === 'function' &&
( ArrayBuffer . isView ( string ) || string instanceof ArrayBuffer ) ) {
return string . byteLength
2015-06-29 16:29:46 +00:00
}
2018-06-28 17:35:20 +00:00
if ( typeof string !== 'string' ) {
string = '' + string
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
var len = string . length
if ( len === 0 ) return 0
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
// Use a for loop to avoid recursion
var loweredCase = false
for ( ; ; ) {
switch ( encoding ) {
case 'ascii' :
case 'latin1' :
case 'binary' :
return len
case 'utf8' :
case 'utf-8' :
case undefined :
return utf8ToBytes ( string ) . length
case 'ucs2' :
case 'ucs-2' :
case 'utf16le' :
case 'utf-16le' :
return len * 2
case 'hex' :
return len >>> 1
case 'base64' :
return base64ToBytes ( string ) . length
default :
if ( loweredCase ) return utf8ToBytes ( string ) . length // assume utf8
encoding = ( '' + encoding ) . toLowerCase ( )
loweredCase = true
}
2015-06-29 16:29:46 +00:00
}
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
Buffer . byteLength = byteLength
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
function slowToString ( encoding , start , end ) {
var loweredCase = false
2015-06-29 16:29:46 +00:00
2018-06-28 17:35:20 +00:00
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
// property of a typed array.
// This behaves neither like String nor Uint8Array in that we set start/end
// to their upper/lower bounds if the value passed is out of range.
// undefined is handled specially as per ECMA-262 6th Edition,
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
if ( start === undefined || start < 0 ) {
start = 0
}
// Return early if start > this.length. Done here to prevent potential uint32
// coercion fail below.
if ( start > this . length ) {
return ''
2015-06-29 16:29:46 +00:00
}
2018-06-28 17:35:20 +00:00
if ( end === undefined || end > this . length ) {
end = this . length
2015-06-29 16:29:46 +00:00
}
2018-06-28 17:35:20 +00:00
if ( end <= 0 ) {
return ''
}
2015-06-29 16:29:46 +00:00
2018-06-28 17:35:20 +00:00
// Force coersion to uint32. This will also coerce falsey/NaN values to 0.
end >>>= 0
start >>>= 0
2015-06-29 16:29:46 +00:00
2018-06-28 17:35:20 +00:00
if ( end <= start ) {
return ''
2015-06-29 16:29:46 +00:00
}
2018-06-28 17:35:20 +00:00
if ( ! encoding ) encoding = 'utf8'
2015-06-29 16:29:46 +00:00
2018-06-28 17:35:20 +00:00
while ( true ) {
switch ( encoding ) {
case 'hex' :
return hexSlice ( this , start , end )
2015-06-29 16:29:46 +00:00
2018-06-28 17:35:20 +00:00
case 'utf8' :
case 'utf-8' :
return utf8Slice ( this , start , end )
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
case 'ascii' :
return asciiSlice ( this , start , end )
case 'latin1' :
case 'binary' :
return latin1Slice ( this , start , end )
case 'base64' :
return base64Slice ( this , start , end )
case 'ucs2' :
case 'ucs-2' :
case 'utf16le' :
case 'utf-16le' :
return utf16leSlice ( this , start , end )
default :
if ( loweredCase ) throw new TypeError ( 'Unknown encoding: ' + encoding )
encoding = ( encoding + '' ) . toLowerCase ( )
loweredCase = true
}
}
}
// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
// Buffer instances.
Buffer . prototype . _isBuffer = true
function swap ( b , n , m ) {
var i = b [ n ]
b [ n ] = b [ m ]
b [ m ] = i
}
Buffer . prototype . swap16 = function swap16 ( ) {
var len = this . length
if ( len % 2 !== 0 ) {
throw new RangeError ( 'Buffer size must be a multiple of 16-bits' )
}
for ( var i = 0 ; i < len ; i += 2 ) {
swap ( this , i , i + 1 )
}
return this
}
Buffer . prototype . swap32 = function swap32 ( ) {
var len = this . length
if ( len % 4 !== 0 ) {
throw new RangeError ( 'Buffer size must be a multiple of 32-bits' )
}
for ( var i = 0 ; i < len ; i += 4 ) {
swap ( this , i , i + 3 )
swap ( this , i + 1 , i + 2 )
}
return this
}
Buffer . prototype . swap64 = function swap64 ( ) {
var len = this . length
if ( len % 8 !== 0 ) {
throw new RangeError ( 'Buffer size must be a multiple of 64-bits' )
}
for ( var i = 0 ; i < len ; i += 8 ) {
swap ( this , i , i + 7 )
swap ( this , i + 1 , i + 6 )
swap ( this , i + 2 , i + 5 )
swap ( this , i + 3 , i + 4 )
}
return this
}
Buffer . prototype . toString = function toString ( ) {
var length = this . length | 0
if ( length === 0 ) return ''
if ( arguments . length === 0 ) return utf8Slice ( this , 0 , length )
return slowToString . apply ( this , arguments )
}
Buffer . prototype . equals = function equals ( b ) {
if ( ! Buffer . isBuffer ( b ) ) throw new TypeError ( 'Argument must be a Buffer' )
if ( this === b ) return true
return Buffer . compare ( this , b ) === 0
}
Buffer . prototype . inspect = function inspect ( ) {
var str = ''
var max = exports . INSPECT _MAX _BYTES
if ( this . length > 0 ) {
str = this . toString ( 'hex' , 0 , max ) . match ( /.{2}/g ) . join ( ' ' )
if ( this . length > max ) str += ' ... '
}
return '<Buffer ' + str + '>'
}
Buffer . prototype . compare = function compare ( target , start , end , thisStart , thisEnd ) {
if ( ! Buffer . isBuffer ( target ) ) {
throw new TypeError ( 'Argument must be a Buffer' )
}
if ( start === undefined ) {
start = 0
}
if ( end === undefined ) {
end = target ? target . length : 0
}
if ( thisStart === undefined ) {
thisStart = 0
}
if ( thisEnd === undefined ) {
thisEnd = this . length
}
if ( start < 0 || end > target . length || thisStart < 0 || thisEnd > this . length ) {
throw new RangeError ( 'out of range index' )
}
if ( thisStart >= thisEnd && start >= end ) {
return 0
}
if ( thisStart >= thisEnd ) {
return - 1
}
if ( start >= end ) {
return 1
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
}
<< << << < HEAD
Buffer . prototype . writeUInt16LE = function writeUInt16LE ( value , offset , noAssert ) {
2015-05-31 15:18:20 +00:00
value = + value
2015-06-29 16:29:46 +00:00
offset = offset | 0
2018-06-28 17:35:20 +00:00
if ( ! noAssert ) checkInt ( this , value , offset , 2 , 0xffff , 0 )
2015-05-31 15:18:20 +00:00
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
2018-05-29 18:03:59 +00:00
this [ offset ] = ( value & 0xff )
2015-05-31 15:18:20 +00:00
this [ offset + 1 ] = ( value >>> 8 )
2015-06-29 16:29:46 +00:00
} else {
objectWriteUInt16 ( this , value , offset , true )
}
2015-05-31 15:18:20 +00:00
return offset + 2
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
Buffer . prototype . writeUInt16BE = function writeUInt16BE ( value , offset , noAssert ) {
2015-05-31 15:18:20 +00:00
value = + value
2015-06-29 16:29:46 +00:00
offset = offset | 0
2018-06-28 17:35:20 +00:00
if ( ! noAssert ) checkInt ( this , value , offset , 2 , 0xffff , 0 )
2015-05-31 15:18:20 +00:00
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value >>> 8 )
2018-05-29 18:03:59 +00:00
this [ offset + 1 ] = ( value & 0xff )
2015-06-29 16:29:46 +00:00
} else {
objectWriteUInt16 ( this , value , offset , false )
}
2015-05-31 15:18:20 +00:00
return offset + 2
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
function objectWriteUInt32 ( buf , value , offset , littleEndian ) {
if ( value < 0 ) value = 0xffffffff + value + 1
for ( var i = 0 , j = Math . min ( buf . length - offset , 4 ) ; i < j ; i ++ ) {
buf [ offset + i ] = ( value >>> ( littleEndian ? i : 3 - i ) * 8 ) & 0xff
=== === =
start >>>= 0
end >>>= 0
thisStart >>>= 0
thisEnd >>>= 0
if ( this === target ) return 0
var x = thisEnd - thisStart
var y = end - start
var len = Math . min ( x , y )
var thisCopy = this . slice ( thisStart , thisEnd )
var targetCopy = target . slice ( start , end )
for ( var i = 0 ; i < len ; ++ i ) {
if ( thisCopy [ i ] !== targetCopy [ i ] ) {
x = thisCopy [ i ]
y = targetCopy [ i ]
break
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
}
<< << << < HEAD
Buffer . prototype . writeUInt32LE = function writeUInt32LE ( value , offset , noAssert ) {
2015-05-31 15:18:20 +00:00
value = + value
2015-06-29 16:29:46 +00:00
offset = offset | 0
2018-06-28 17:35:20 +00:00
if ( ! noAssert ) checkInt ( this , value , offset , 4 , 0xffffffff , 0 )
2015-05-31 15:18:20 +00:00
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset + 3 ] = ( value >>> 24 )
2018-06-28 17:35:20 +00:00
this [ offset + 2 ] = ( value >>> 16 )
this [ offset + 1 ] = ( value >>> 8 )
this [ offset ] = ( value & 0xff )
2015-06-29 16:29:46 +00:00
} else {
objectWriteUInt32 ( this , value , offset , true )
2018-06-28 17:35:20 +00:00
=== === =
if ( x < y ) return - 1
if ( y < x ) return 1
return 0
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
//
// Arguments:
// - buffer - a Buffer to search
// - val - a string, Buffer, or number
// - byteOffset - an index into `buffer`; will be clamped to an int32
// - encoding - an optional encoding, relevant is val is a string
// - dir - true for indexOf, false for lastIndexOf
function bidirectionalIndexOf ( buffer , val , byteOffset , encoding , dir ) {
// Empty buffer means no match
if ( buffer . length === 0 ) return - 1
// Normalize byteOffset
if ( typeof byteOffset === 'string' ) {
encoding = byteOffset
byteOffset = 0
} else if ( byteOffset > 0x7fffffff ) {
byteOffset = 0x7fffffff
} else if ( byteOffset < - 0x80000000 ) {
byteOffset = - 0x80000000
}
byteOffset = + byteOffset // Coerce to Number.
if ( isNaN ( byteOffset ) ) {
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
byteOffset = dir ? 0 : ( buffer . length - 1 )
}
// Normalize byteOffset: negative offsets start from the end of the buffer
if ( byteOffset < 0 ) byteOffset = buffer . length + byteOffset
if ( byteOffset >= buffer . length ) {
if ( dir ) return - 1
else byteOffset = buffer . length - 1
} else if ( byteOffset < 0 ) {
if ( dir ) byteOffset = 0
else return - 1
}
// Normalize val
if ( typeof val === 'string' ) {
val = Buffer . from ( val , encoding )
}
// Finally, search either indexOf (if dir is true) or lastIndexOf
if ( Buffer . isBuffer ( val ) ) {
// Special case: looking for empty string/buffer always fails
if ( val . length === 0 ) {
return - 1
}
return arrayIndexOf ( buffer , val , byteOffset , encoding , dir )
} else if ( typeof val === 'number' ) {
val = val & 0xFF // Search for a byte value [0-255]
if ( Buffer . TYPED _ARRAY _SUPPORT &&
typeof Uint8Array . prototype . indexOf === 'function' ) {
if ( dir ) {
return Uint8Array . prototype . indexOf . call ( buffer , val , byteOffset )
} else {
return Uint8Array . prototype . lastIndexOf . call ( buffer , val , byteOffset )
}
}
return arrayIndexOf ( buffer , [ val ] , byteOffset , encoding , dir )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
<< << << < HEAD
Buffer . prototype . writeUInt32BE = function writeUInt32BE ( value , offset , noAssert ) {
2015-05-31 15:18:20 +00:00
value = + value
2015-06-29 16:29:46 +00:00
offset = offset | 0
2018-06-28 17:35:20 +00:00
if ( ! noAssert ) checkInt ( this , value , offset , 4 , 0xffffffff , 0 )
2015-05-31 15:18:20 +00:00
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value >>> 24 )
this [ offset + 1 ] = ( value >>> 16 )
this [ offset + 2 ] = ( value >>> 8 )
2018-05-29 18:03:59 +00:00
this [ offset + 3 ] = ( value & 0xff )
2015-06-29 16:29:46 +00:00
} else {
objectWriteUInt32 ( this , value , offset , false )
}
2015-05-31 15:18:20 +00:00
return offset + 4
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
Buffer . prototype . writeIntLE = function writeIntLE ( value , offset , byteLength , noAssert ) {
value = + value
offset = offset | 0
2015-06-29 16:29:46 +00:00
if ( ! noAssert ) {
2018-06-28 17:35:20 +00:00
var limit = Math . pow ( 2 , 8 * byteLength - 1 )
checkInt ( this , value , offset , byteLength , limit - 1 , - limit )
2015-06-29 16:29:46 +00:00
}
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
var i = 0
var mul = 1
var sub = value < 0 ? 1 : 0
this [ offset ] = value & 0xFF
while ( ++ i < byteLength && ( mul *= 0x100 ) ) {
this [ offset + i ] = ( ( value / mul ) >> 0 ) - sub & 0xFF
}
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
return offset + byteLength
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
Buffer . prototype . writeIntBE = function writeIntBE ( value , offset , byteLength , noAssert ) {
value = + value
offset = offset | 0
2015-06-29 16:29:46 +00:00
if ( ! noAssert ) {
2018-06-28 17:35:20 +00:00
var limit = Math . pow ( 2 , 8 * byteLength - 1 )
checkInt ( this , value , offset , byteLength , limit - 1 , - limit )
2015-06-29 16:29:46 +00:00
}
2018-06-28 17:35:20 +00:00
var i = byteLength - 1
var mul = 1
var sub = value < 0 ? 1 : 0
this [ offset + i ] = value & 0xFF
while ( -- i >= 0 && ( mul *= 0x100 ) ) {
this [ offset + i ] = ( ( value / mul ) >> 0 ) - sub & 0xFF
}
return offset + byteLength
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
Buffer . prototype . writeInt8 = function writeInt8 ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 1 , 0x7f , - 0x80 )
if ( ! Buffer . TYPED _ARRAY _SUPPORT ) value = Math . floor ( value )
if ( value < 0 ) value = 0xff + value + 1
this [ offset ] = ( value & 0xff )
return offset + 1
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
Buffer . prototype . writeInt16LE = function writeInt16LE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 2 , 0x7fff , - 0x8000 )
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value & 0xff )
this [ offset + 1 ] = ( value >>> 8 )
} else {
objectWriteUInt16 ( this , value , offset , true )
}
return offset + 2
2015-05-31 15:18:20 +00:00
}
2018-06-28 17:35:20 +00:00
Buffer . prototype . writeInt16BE = function writeInt16BE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 2 , 0x7fff , - 0x8000 )
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value >>> 8 )
this [ offset + 1 ] = ( value & 0xff )
} else {
objectWriteUInt16 ( this , value , offset , false )
=== === =
throw new TypeError ( 'val must be string, number or Buffer' )
}
2015-05-31 15:18:20 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
=== === =
function arrayIndexOf ( arr , val , byteOffset , encoding , dir ) {
var indexSize = 1
var arrLength = arr . length
var valLength = val . length
2015-05-31 15:18:20 +00:00
2018-06-28 17:35:20 +00:00
if ( encoding !== undefined ) {
encoding = String ( encoding ) . toLowerCase ( )
if ( encoding === 'ucs2' || encoding === 'ucs-2' ||
encoding === 'utf16le' || encoding === 'utf-16le' ) {
if ( arr . length < 2 || val . length < 2 ) {
return - 1
}
indexSize = 2
arrLength /= 2
valLength /= 2
byteOffset /= 2
}
2015-06-29 16:29:46 +00:00
}
2015-05-31 15:18:20 +00:00
2018-06-28 17:35:20 +00:00
function read ( buf , i ) {
if ( indexSize === 1 ) {
return buf [ i ]
} else {
return buf . readUInt16BE ( i * indexSize )
}
2015-06-29 16:29:46 +00:00
}
2015-05-31 15:18:20 +00:00
2018-05-29 18:03:59 +00:00
var i
2018-06-28 17:35:20 +00:00
if ( dir ) {
var foundIndex = - 1
for ( i = byteOffset ; i < arrLength ; i ++ ) {
if ( read ( arr , i ) === read ( val , foundIndex === - 1 ? 0 : i - foundIndex ) ) {
if ( foundIndex === - 1 ) foundIndex = i
if ( i - foundIndex + 1 === valLength ) return foundIndex * indexSize
} else {
if ( foundIndex !== - 1 ) i -= i - foundIndex
foundIndex = - 1
}
2015-05-31 15:18:20 +00:00
}
} else {
2018-06-28 17:35:20 +00:00
if ( byteOffset + valLength > arrLength ) byteOffset = arrLength - valLength
for ( i = byteOffset ; i >= 0 ; i -- ) {
var found = true
for ( var j = 0 ; j < valLength ; j ++ ) {
if ( read ( arr , i + j ) !== read ( val , j ) ) {
found = false
break
}
}
if ( found ) return i
}
}
return - 1
}
Buffer . prototype . includes = function includes ( val , byteOffset , encoding ) {
return this . indexOf ( val , byteOffset , encoding ) !== - 1
}
Buffer . prototype . indexOf = function indexOf ( val , byteOffset , encoding ) {
return bidirectionalIndexOf ( this , val , byteOffset , encoding , true )
}
Buffer . prototype . lastIndexOf = function lastIndexOf ( val , byteOffset , encoding ) {
return bidirectionalIndexOf ( this , val , byteOffset , encoding , false )
}
function hexWrite ( buf , string , offset , length ) {
offset = Number ( offset ) || 0
var remaining = buf . length - offset
if ( ! length ) {
length = remaining
} else {
length = Number ( length )
if ( length > remaining ) {
length = remaining
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
return offset + 2
}
<< << << < HEAD
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
Buffer . prototype . writeInt32LE = function writeInt32LE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 4 , 0x7fffffff , - 0x80000000 )
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
<< << << < HEAD
this [ offset ] = ( value & 0xff )
=== === =
this [ offset ] = value
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
this [ offset + 1 ] = ( value >>> 8 )
this [ offset + 2 ] = ( value >>> 16 )
this [ offset + 3 ] = ( value >>> 24 )
} else {
objectWriteUInt32 ( this , value , offset , true )
}
return offset + 4
}
Buffer . prototype . writeInt32BE = function writeInt32BE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 4 , 0x7fffffff , - 0x80000000 )
if ( value < 0 ) value = 0xffffffff + value + 1
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value >>> 24 )
this [ offset + 1 ] = ( value >>> 16 )
this [ offset + 2 ] = ( value >>> 8 )
this [ offset + 3 ] = ( value & 0xff )
} else {
objectWriteUInt32 ( this , value , offset , false )
}
return offset + 4
}
function checkIEEE754 ( buf , value , offset , ext , max , min ) {
if ( value > max || value < min ) throw new RangeError ( 'value is out of bounds' )
if ( offset + ext > buf . length ) throw new RangeError ( 'index out of range' )
if ( offset < 0 ) throw new RangeError ( 'index out of range' )
}
function writeFloat ( buf , value , offset , littleEndian , noAssert ) {
if ( ! noAssert ) {
checkIEEE754 ( buf , value , offset , 4 , 3.4028234663852886 e + 38 , - 3.4028234663852886 e + 38 )
}
ieee754 . write ( buf , value , offset , littleEndian , 23 , 4 )
return offset + 4
}
Buffer . prototype . writeFloatLE = function writeFloatLE ( value , offset , noAssert ) {
return writeFloat ( this , value , offset , true , noAssert )
}
Buffer . prototype . writeFloatBE = function writeFloatBE ( value , offset , noAssert ) {
return writeFloat ( this , value , offset , false , noAssert )
}
function writeDouble ( buf , value , offset , littleEndian , noAssert ) {
if ( ! noAssert ) {
checkIEEE754 ( buf , value , offset , 8 , 1.7976931348623157 E + 308 , - 1.7976931348623157 E + 308 )
}
ieee754 . write ( buf , value , offset , littleEndian , 52 , 8 )
return offset + 8
}
Buffer . prototype . writeDoubleLE = function writeDoubleLE ( value , offset , noAssert ) {
return writeDouble ( this , value , offset , true , noAssert )
}
Buffer . prototype . writeDoubleBE = function writeDoubleBE ( value , offset , noAssert ) {
return writeDouble ( this , value , offset , false , noAssert )
}
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
Buffer . prototype . copy = function copy ( target , targetStart , start , end ) {
if ( ! start ) start = 0
if ( ! end && end !== 0 ) end = this . length
if ( targetStart >= target . length ) targetStart = target . length
if ( ! targetStart ) targetStart = 0
if ( end > 0 && end < start ) end = start
// Copy 0 bytes; we're done
if ( end === start ) return 0
if ( target . length === 0 || this . length === 0 ) return 0
// Fatal error conditions
if ( targetStart < 0 ) {
throw new RangeError ( 'targetStart out of bounds' )
}
if ( start < 0 || start >= this . length ) throw new RangeError ( 'sourceStart out of bounds' )
if ( end < 0 ) throw new RangeError ( 'sourceEnd out of bounds' )
// Are we oob?
if ( end > this . length ) end = this . length
if ( target . length - targetStart < end - start ) {
end = target . length - targetStart + start
}
var len = end - start
var i
if ( this === target && start < targetStart && targetStart < end ) {
// descending copy from end
for ( i = len - 1 ; i >= 0 ; i -- ) {
target [ i + targetStart ] = this [ i + start ]
}
} else if ( len < 1000 || ! Buffer . TYPED _ARRAY _SUPPORT ) {
// ascending copy from start
for ( i = 0 ; i < len ; i ++ ) {
target [ i + targetStart ] = this [ i + start ]
}
} else {
target . _set ( this . subarray ( start , start + len ) , targetStart )
2015-05-31 15:18:20 +00:00
}
2015-06-29 16:29:46 +00:00
return len
2014-06-10 18:53:04 +00:00
}
// fill(value, start=0, end=buffer.length)
2015-06-29 16:29:46 +00:00
Buffer . prototype . fill = function fill ( value , start , end ) {
2014-06-10 18:53:04 +00:00
if ( ! value ) value = 0
if ( ! start ) start = 0
if ( ! end ) end = this . length
2015-06-29 16:29:46 +00:00
if ( end < start ) throw new RangeError ( 'end < start' )
2018-06-28 17:35:20 +00:00
=== === =
// must be an even number of digits
var strLen = string . length
if ( strLen % 2 !== 0 ) throw new TypeError ( 'Invalid hex string' )
if ( length > strLen / 2 ) {
length = strLen / 2
}
for ( var i = 0 ; i < length ; ++ i ) {
var parsed = parseInt ( string . substr ( i * 2 , 2 ) , 16 )
if ( isNaN ( parsed ) ) return i
buf [ offset + i ] = parsed
}
return i
}
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
function utf8Write ( buf , string , offset , length ) {
return blitBuffer ( utf8ToBytes ( string , buf . length - offset ) , buf , offset , length )
}
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
function asciiWrite ( buf , string , offset , length ) {
return blitBuffer ( asciiToBytes ( string ) , buf , offset , length )
}
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
function latin1Write ( buf , string , offset , length ) {
return asciiWrite ( buf , string , offset , length )
}
function base64Write ( buf , string , offset , length ) {
return blitBuffer ( base64ToBytes ( string ) , buf , offset , length )
}
function ucs2Write ( buf , string , offset , length ) {
return blitBuffer ( utf16leToBytes ( string , buf . length - offset ) , buf , offset , length )
}
Buffer . prototype . write = function write ( string , offset , length , encoding ) {
// Buffer#write(string)
if ( offset === undefined ) {
encoding = 'utf8'
length = this . length
offset = 0
// Buffer#write(string, encoding)
} else if ( length === undefined && typeof offset === 'string' ) {
encoding = offset
length = this . length
offset = 0
// Buffer#write(string, offset[, length][, encoding])
} else if ( isFinite ( offset ) ) {
offset = offset | 0
if ( isFinite ( length ) ) {
length = length | 0
if ( encoding === undefined ) encoding = 'utf8'
} else {
encoding = length
length = undefined
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
// legacy write(string, encoding, offset, length) - remove in v0.13
2014-06-10 18:53:04 +00:00
} else {
2018-06-28 17:35:20 +00:00
throw new Error (
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
)
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
var remaining = this . length - offset
if ( length === undefined || length > remaining ) length = remaining
if ( ( string . length > 0 && ( length < 0 || offset < 0 ) ) || offset > this . length ) {
throw new RangeError ( 'Attempt to write outside buffer bounds' )
}
if ( ! encoding ) encoding = 'utf8'
var loweredCase = false
for ( ; ; ) {
switch ( encoding ) {
case 'hex' :
return hexWrite ( this , string , offset , length )
case 'utf8' :
case 'utf-8' :
return utf8Write ( this , string , offset , length )
case 'ascii' :
return asciiWrite ( this , string , offset , length )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
case 'latin1' :
case 'binary' :
return latin1Write ( this , string , offset , length )
<< << << < HEAD
if ( start < 0 || start >= this . length ) throw new RangeError ( 'start out of bounds' )
if ( end < 0 || end > this . length ) throw new RangeError ( 'end out of bounds' )
=== === =
case 'base64' :
// Warning: maxLength not taken into account in base64Write
return base64Write ( this , string , offset , length )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
case 'ucs2' :
case 'ucs-2' :
case 'utf16le' :
case 'utf-16le' :
return ucs2Write ( this , string , offset , length )
default :
if ( loweredCase ) throw new TypeError ( 'Unknown encoding: ' + encoding )
encoding = ( '' + encoding ) . toLowerCase ( )
loweredCase = true
}
}
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-06-10 18:53:04 +00:00
/ * *
* Creates a new ` ArrayBuffer ` with the * copied * memory of the buffer instance .
* Added in Node 0.12 . Only available in browsers that support ArrayBuffer .
* /
2015-06-29 16:29:46 +00:00
Buffer . prototype . toArrayBuffer = function toArrayBuffer ( ) {
2014-06-10 18:53:04 +00:00
if ( typeof Uint8Array !== 'undefined' ) {
2015-05-31 15:18:20 +00:00
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
2014-06-10 18:53:04 +00:00
return ( new Buffer ( this ) ) . buffer
} else {
var buf = new Uint8Array ( this . length )
for ( var i = 0 , len = buf . length ; i < len ; i += 1 ) {
buf [ i ] = this [ i ]
}
return buf . buffer
}
} else {
2015-05-31 15:18:20 +00:00
throw new TypeError ( 'Buffer.toArrayBuffer not supported in this browser' )
2018-06-28 17:35:20 +00:00
=== === =
Buffer . prototype . toJSON = function toJSON ( ) {
return {
type : 'Buffer' ,
data : Array . prototype . slice . call ( this . _arr || this , 0 )
2014-06-10 18:53:04 +00:00
}
}
2018-06-28 17:35:20 +00:00
function base64Slice ( buf , start , end ) {
if ( start === 0 && end === buf . length ) {
return base64 . fromByteArray ( buf )
} else {
return base64 . fromByteArray ( buf . slice ( start , end ) )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
}
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
function utf8Slice ( buf , start , end ) {
end = Math . min ( buf . length , end )
var res = [ ]
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
var i = start
while ( i < end ) {
var firstByte = buf [ i ]
var codePoint = null
var bytesPerSequence = ( firstByte > 0xEF ) ? 4
: ( firstByte > 0xDF ) ? 3
: ( firstByte > 0xBF ) ? 2
: 1
if ( i + bytesPerSequence <= end ) {
var secondByte , thirdByte , fourthByte , tempCodePoint
switch ( bytesPerSequence ) {
case 1 :
if ( firstByte < 0x80 ) {
codePoint = firstByte
}
break
case 2 :
secondByte = buf [ i + 1 ]
if ( ( secondByte & 0xC0 ) === 0x80 ) {
tempCodePoint = ( firstByte & 0x1F ) << 0x6 | ( secondByte & 0x3F )
if ( tempCodePoint > 0x7F ) {
codePoint = tempCodePoint
}
}
break
case 3 :
secondByte = buf [ i + 1 ]
thirdByte = buf [ i + 2 ]
if ( ( secondByte & 0xC0 ) === 0x80 && ( thirdByte & 0xC0 ) === 0x80 ) {
tempCodePoint = ( firstByte & 0xF ) << 0xC | ( secondByte & 0x3F ) << 0x6 | ( thirdByte & 0x3F )
if ( tempCodePoint > 0x7FF && ( tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF ) ) {
codePoint = tempCodePoint
}
}
break
case 4 :
secondByte = buf [ i + 1 ]
thirdByte = buf [ i + 2 ]
fourthByte = buf [ i + 3 ]
if ( ( secondByte & 0xC0 ) === 0x80 && ( thirdByte & 0xC0 ) === 0x80 && ( fourthByte & 0xC0 ) === 0x80 ) {
tempCodePoint = ( firstByte & 0xF ) << 0x12 | ( secondByte & 0x3F ) << 0xC | ( thirdByte & 0x3F ) << 0x6 | ( fourthByte & 0x3F )
if ( tempCodePoint > 0xFFFF && tempCodePoint < 0x110000 ) {
codePoint = tempCodePoint
}
}
}
}
if ( codePoint === null ) {
// we did not generate a valid codePoint so insert a
// replacement char (U+FFFD) and advance only 1 byte
codePoint = 0xFFFD
bytesPerSequence = 1
} else if ( codePoint > 0xFFFF ) {
// encode to utf16 (surrogate pair dance)
codePoint -= 0x10000
res . push ( codePoint >>> 10 & 0x3FF | 0xD800 )
codePoint = 0xDC00 | codePoint & 0x3FF
}
<< << << < HEAD
/ * *
* Augment a Uint8Array * instance * ( not the Uint8Array class ! ) with Buffer methods
* /
Buffer . _augment = function _augment ( arr ) {
arr . constructor = Buffer
2014-06-10 18:53:04 +00:00
arr . _isBuffer = true
2015-06-29 16:29:46 +00:00
// save reference to original Uint8Array set method before overwriting
2014-06-10 18:53:04 +00:00
arr . _set = arr . set
2018-05-29 18:03:59 +00:00
// deprecated
2014-06-10 18:53:04 +00:00
arr . get = BP . get
arr . set = BP . set
arr . write = BP . write
arr . toString = BP . toString
arr . toLocaleString = BP . toString
arr . toJSON = BP . toJSON
arr . equals = BP . equals
arr . compare = BP . compare
2015-06-29 16:29:46 +00:00
arr . indexOf = BP . indexOf
2014-06-10 18:53:04 +00:00
arr . copy = BP . copy
arr . slice = BP . slice
2015-06-29 16:29:46 +00:00
arr . readUIntLE = BP . readUIntLE
arr . readUIntBE = BP . readUIntBE
2014-06-10 18:53:04 +00:00
arr . readUInt8 = BP . readUInt8
arr . readUInt16LE = BP . readUInt16LE
arr . readUInt16BE = BP . readUInt16BE
arr . readUInt32LE = BP . readUInt32LE
arr . readUInt32BE = BP . readUInt32BE
2015-06-29 16:29:46 +00:00
arr . readIntLE = BP . readIntLE
arr . readIntBE = BP . readIntBE
2014-06-10 18:53:04 +00:00
arr . readInt8 = BP . readInt8
arr . readInt16LE = BP . readInt16LE
arr . readInt16BE = BP . readInt16BE
arr . readInt32LE = BP . readInt32LE
arr . readInt32BE = BP . readInt32BE
arr . readFloatLE = BP . readFloatLE
arr . readFloatBE = BP . readFloatBE
arr . readDoubleLE = BP . readDoubleLE
arr . readDoubleBE = BP . readDoubleBE
arr . writeUInt8 = BP . writeUInt8
2015-06-29 16:29:46 +00:00
arr . writeUIntLE = BP . writeUIntLE
arr . writeUIntBE = BP . writeUIntBE
2014-06-10 18:53:04 +00:00
arr . writeUInt16LE = BP . writeUInt16LE
arr . writeUInt16BE = BP . writeUInt16BE
arr . writeUInt32LE = BP . writeUInt32LE
arr . writeUInt32BE = BP . writeUInt32BE
2015-06-29 16:29:46 +00:00
arr . writeIntLE = BP . writeIntLE
arr . writeIntBE = BP . writeIntBE
2014-06-10 18:53:04 +00:00
arr . writeInt8 = BP . writeInt8
arr . writeInt16LE = BP . writeInt16LE
arr . writeInt16BE = BP . writeInt16BE
arr . writeInt32LE = BP . writeInt32LE
arr . writeInt32BE = BP . writeInt32BE
arr . writeFloatLE = BP . writeFloatLE
arr . writeFloatBE = BP . writeFloatBE
arr . writeDoubleLE = BP . writeDoubleLE
arr . writeDoubleBE = BP . writeDoubleBE
arr . fill = BP . fill
arr . inspect = BP . inspect
arr . toArrayBuffer = BP . toArrayBuffer
2018-06-28 17:35:20 +00:00
=== === =
res . push ( codePoint )
i += bytesPerSequence
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
return decodeCodePointsArray ( res )
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
var INVALID _BASE64 _RE = /[^+\/0-9A-Za-z-_]/g
2018-06-28 17:35:20 +00:00
=== === =
<< << << < HEAD
var INVALID _BASE64 _RE = /[^+\/0-9A-z\-]/g
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-06-10 18:53:04 +00:00
2015-05-31 15:18:20 +00:00
function base64clean ( str ) {
// Node strips out invalid characters like \n and \t from the string, base64-js does not
str = stringtrim ( str ) . replace ( INVALID _BASE64 _RE , '' )
2015-06-29 16:29:46 +00:00
// Node converts strings with length < 2 to ''
if ( str . length < 2 ) return ''
2015-05-31 15:18:20 +00:00
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
while ( str . length % 4 !== 0 ) {
str = str + '='
2018-06-28 17:35:20 +00:00
=== === =
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
// the lowest limit is Chrome, with 0x10000 args.
// We go 1 magnitude less, for safety
var MAX _ARGUMENTS _LENGTH = 0x1000
function decodeCodePointsArray ( codePoints ) {
var len = codePoints . length
if ( len <= MAX _ARGUMENTS _LENGTH ) {
return String . fromCharCode . apply ( String , codePoints ) // avoid extra slice()
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2015-05-31 15:18:20 +00:00
}
2014-06-10 18:53:04 +00:00
2018-06-28 17:35:20 +00:00
// Decode in chunks to avoid "call stack size exceeded".
var res = ''
var i = 0
while ( i < len ) {
res += String . fromCharCode . apply (
String ,
codePoints . slice ( i , i += MAX _ARGUMENTS _LENGTH )
)
}
return res
2014-06-10 18:53:04 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-06-10 18:53:04 +00:00
function toHex ( n ) {
if ( n < 16 ) return '0' + n . toString ( 16 )
return n . toString ( 16 )
}
2015-06-29 16:29:46 +00:00
function utf8ToBytes ( string , units ) {
units = units || Infinity
var codePoint
var length = string . length
var leadSurrogate = null
var bytes = [ ]
2018-05-29 18:03:59 +00:00
for ( var i = 0 ; i < length ; i ++ ) {
2015-06-29 16:29:46 +00:00
codePoint = string . charCodeAt ( i )
// is surrogate component
if ( codePoint > 0xD7FF && codePoint < 0xE000 ) {
// last char was a lead
2018-05-29 18:03:59 +00:00
if ( ! leadSurrogate ) {
2015-06-29 16:29:46 +00:00
// no lead yet
if ( codePoint > 0xDBFF ) {
// unexpected trail
if ( ( units -= 3 ) > - 1 ) bytes . push ( 0xEF , 0xBF , 0xBD )
continue
} else if ( i + 1 === length ) {
// unpaired lead
if ( ( units -= 3 ) > - 1 ) bytes . push ( 0xEF , 0xBF , 0xBD )
continue
}
2018-05-29 18:03:59 +00:00
// valid lead
leadSurrogate = codePoint
continue
}
// 2 leads in a row
if ( codePoint < 0xDC00 ) {
if ( ( units -= 3 ) > - 1 ) bytes . push ( 0xEF , 0xBF , 0xBD )
leadSurrogate = codePoint
continue
2014-06-10 18:53:04 +00:00
}
2018-05-29 18:03:59 +00:00
// valid surrogate pair
codePoint = ( leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 ) + 0x10000
2015-06-29 16:29:46 +00:00
} else if ( leadSurrogate ) {
// valid bmp char, but last char was a lead
if ( ( units -= 3 ) > - 1 ) bytes . push ( 0xEF , 0xBF , 0xBD )
}
2018-05-29 18:03:59 +00:00
leadSurrogate = null
2015-06-29 16:29:46 +00:00
// encode utf8
if ( codePoint < 0x80 ) {
if ( ( units -= 1 ) < 0 ) break
bytes . push ( codePoint )
} else if ( codePoint < 0x800 ) {
if ( ( units -= 2 ) < 0 ) break
bytes . push (
codePoint >> 0x6 | 0xC0 ,
codePoint & 0x3F | 0x80
)
} else if ( codePoint < 0x10000 ) {
if ( ( units -= 3 ) < 0 ) break
bytes . push (
codePoint >> 0xC | 0xE0 ,
codePoint >> 0x6 & 0x3F | 0x80 ,
codePoint & 0x3F | 0x80
)
2018-05-29 18:03:59 +00:00
} else if ( codePoint < 0x110000 ) {
2015-06-29 16:29:46 +00:00
if ( ( units -= 4 ) < 0 ) break
bytes . push (
codePoint >> 0x12 | 0xF0 ,
codePoint >> 0xC & 0x3F | 0x80 ,
codePoint >> 0x6 & 0x3F | 0x80 ,
codePoint & 0x3F | 0x80
)
} else {
throw new Error ( 'Invalid code point' )
2014-06-10 18:53:04 +00:00
}
}
2015-06-29 16:29:46 +00:00
return bytes
2014-06-10 18:53:04 +00:00
}
function asciiToBytes ( str ) {
var byteArray = [ ]
for ( var i = 0 ; i < str . length ; i ++ ) {
// Node's code seems to be doing this and not & 0x7F..
byteArray . push ( str . charCodeAt ( i ) & 0xFF )
}
return byteArray
}
2015-06-29 16:29:46 +00:00
function utf16leToBytes ( str , units ) {
2014-06-10 18:53:04 +00:00
var c , hi , lo
var byteArray = [ ]
for ( var i = 0 ; i < str . length ; i ++ ) {
2015-06-29 16:29:46 +00:00
if ( ( units -= 2 ) < 0 ) break
2014-06-10 18:53:04 +00:00
c = str . charCodeAt ( i )
hi = c >> 8
lo = c % 256
byteArray . push ( lo )
byteArray . push ( hi )
}
return byteArray
}
function base64ToBytes ( str ) {
2015-06-29 16:29:46 +00:00
return base64 . toByteArray ( base64clean ( str ) )
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
function blitBuffer ( src , dst , offset , length ) {
2014-06-10 18:53:04 +00:00
for ( var i = 0 ; i < length ; i ++ ) {
2015-06-29 16:29:46 +00:00
if ( ( i + offset >= dst . length ) || ( i >= src . length ) ) break
2014-06-10 18:53:04 +00:00
dst [ i + offset ] = src [ i ]
}
return i
}
2018-05-29 18:03:59 +00:00
} ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } )
} , { "base64-js" : 6 , "ieee754" : 9 , "isarray" : 8 } ] , 8 : [ function ( require , module , exports ) {
var toString = { } . toString ;
2014-06-10 18:53:04 +00:00
2018-05-29 18:03:59 +00:00
module . exports = Array . isArray || function ( arr ) {
return toString . call ( arr ) == '[object Array]' ;
} ;
2014-06-10 18:53:04 +00:00
2018-05-29 18:03:59 +00:00
} , { } ] , 9 : [ function ( require , module , exports ) {
exports . read = function ( buffer , offset , isLE , mLen , nBytes ) {
var e , m
var eLen = ( nBytes * 8 ) - mLen - 1
var eMax = ( 1 << eLen ) - 1
var eBias = eMax >> 1
var nBits = - 7
var i = isLE ? ( nBytes - 1 ) : 0
var d = isLE ? - 1 : 1
var s = buffer [ offset + i ]
2014-06-10 18:53:04 +00:00
2018-05-29 18:03:59 +00:00
i += d
2015-06-29 16:29:46 +00:00
e = s & ( ( 1 << ( - nBits ) ) - 1 )
s >>= ( - nBits )
nBits += eLen
2018-05-29 18:03:59 +00:00
for ( ; nBits > 0 ; e = ( e * 256 ) + buffer [ offset + i ] , i += d , nBits -= 8 ) { }
2015-06-29 16:29:46 +00:00
m = e & ( ( 1 << ( - nBits ) ) - 1 )
e >>= ( - nBits )
nBits += mLen
2018-05-29 18:03:59 +00:00
for ( ; nBits > 0 ; m = ( m * 256 ) + buffer [ offset + i ] , i += d , nBits -= 8 ) { }
2014-06-10 18:53:04 +00:00
if ( e === 0 ) {
2015-06-29 16:29:46 +00:00
e = 1 - eBias
2014-06-10 18:53:04 +00:00
} else if ( e === eMax ) {
2015-06-29 16:29:46 +00:00
return m ? NaN : ( ( s ? - 1 : 1 ) * Infinity )
2014-06-10 18:53:04 +00:00
} else {
2015-06-29 16:29:46 +00:00
m = m + Math . pow ( 2 , mLen )
e = e - eBias
2014-06-10 18:53:04 +00:00
}
2015-06-29 16:29:46 +00:00
return ( s ? - 1 : 1 ) * m * Math . pow ( 2 , e - mLen )
}
2014-06-10 18:53:04 +00:00
2015-06-29 16:29:46 +00:00
exports . write = function ( buffer , value , offset , isLE , mLen , nBytes ) {
var e , m , c
2018-05-29 18:03:59 +00:00
var eLen = ( nBytes * 8 ) - mLen - 1
2015-06-29 16:29:46 +00:00
var eMax = ( 1 << eLen ) - 1
var eBias = eMax >> 1
var rt = ( mLen === 23 ? Math . pow ( 2 , - 24 ) - Math . pow ( 2 , - 77 ) : 0 )
var i = isLE ? 0 : ( nBytes - 1 )
var d = isLE ? 1 : - 1
var s = value < 0 || ( value === 0 && 1 / value < 0 ) ? 1 : 0
2014-06-10 18:53:04 +00:00
2015-06-29 16:29:46 +00:00
value = Math . abs ( value )
2014-06-10 18:53:04 +00:00
if ( isNaN ( value ) || value === Infinity ) {
2015-06-29 16:29:46 +00:00
m = isNaN ( value ) ? 1 : 0
e = eMax
2014-06-10 18:53:04 +00:00
} else {
2015-06-29 16:29:46 +00:00
e = Math . floor ( Math . log ( value ) / Math . LN2 )
2014-06-10 18:53:04 +00:00
if ( value * ( c = Math . pow ( 2 , - e ) ) < 1 ) {
2015-06-29 16:29:46 +00:00
e --
c *= 2
2014-06-10 18:53:04 +00:00
}
if ( e + eBias >= 1 ) {
2015-06-29 16:29:46 +00:00
value += rt / c
2014-06-10 18:53:04 +00:00
} else {
2015-06-29 16:29:46 +00:00
value += rt * Math . pow ( 2 , 1 - eBias )
2014-06-10 18:53:04 +00:00
}
if ( value * c >= 2 ) {
2015-06-29 16:29:46 +00:00
e ++
c /= 2
2014-06-10 18:53:04 +00:00
}
if ( e + eBias >= eMax ) {
2015-06-29 16:29:46 +00:00
m = 0
e = eMax
2014-06-10 18:53:04 +00:00
} else if ( e + eBias >= 1 ) {
2018-05-29 18:03:59 +00:00
m = ( ( value * c ) - 1 ) * Math . pow ( 2 , mLen )
2015-06-29 16:29:46 +00:00
e = e + eBias
2014-06-10 18:53:04 +00:00
} else {
2015-06-29 16:29:46 +00:00
m = value * Math . pow ( 2 , eBias - 1 ) * Math . pow ( 2 , mLen )
e = 0
2014-06-10 18:53:04 +00:00
}
}
2015-06-29 16:29:46 +00:00
for ( ; mLen >= 8 ; buffer [ offset + i ] = m & 0xff , i += d , m /= 256 , mLen -= 8 ) { }
2014-06-10 18:53:04 +00:00
2015-06-29 16:29:46 +00:00
e = ( e << mLen ) | m
eLen += mLen
for ( ; eLen > 0 ; buffer [ offset + i ] = e & 0xff , i += d , e /= 256 , eLen -= 8 ) { }
2014-06-10 18:53:04 +00:00
2015-06-29 16:29:46 +00:00
buffer [ offset + i - d ] |= s * 128
}
2014-06-10 18:53:04 +00:00
2018-05-29 18:03:59 +00:00
} , { } ] , 10 : [ function ( require , module , exports ) {
; ( function ( ) { // closure for web browsers
2015-05-31 15:18:20 +00:00
2018-05-29 18:03:59 +00:00
if ( typeof module === 'object' && module . exports ) {
module . exports = LRUCache
} else {
// just set the global for non-node platforms.
this . LRUCache = LRUCache
}
2015-05-31 15:18:20 +00:00
2018-05-29 18:03:59 +00:00
function hOP ( obj , key ) {
return Object . prototype . hasOwnProperty . call ( obj , key )
}
2015-05-31 15:18:20 +00:00
2018-05-29 18:03:59 +00:00
function naiveLength ( ) { return 1 }
2015-05-31 15:18:20 +00:00
2018-05-29 18:03:59 +00:00
function LRUCache ( options ) {
if ( ! ( this instanceof LRUCache ) )
return new LRUCache ( options )
2015-05-31 15:18:20 +00:00
2018-05-29 18:03:59 +00:00
if ( typeof options === 'number' )
options = { max : options }
2015-05-31 15:18:20 +00:00
2018-05-29 18:03:59 +00:00
if ( ! options )
options = { }
2015-05-31 15:18:20 +00:00
2018-05-29 18:03:59 +00:00
this . _max = options . max
// Kind of weird to have a default max of Infinity, but oh well.
if ( ! this . _max || ! ( typeof this . _max === "number" ) || this . _max <= 0 )
this . _max = Infinity
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
this . _lengthCalculator = options . length || naiveLength
if ( typeof this . _lengthCalculator !== "function" )
this . _lengthCalculator = naiveLength
this . _allowStale = options . stale || false
this . _maxAge = options . maxAge || null
this . _dispose = options . dispose
this . reset ( )
}
// resize the cache when the max changes.
Object . defineProperty ( LRUCache . prototype , "max" ,
{ set : function ( mL ) {
if ( ! mL || ! ( typeof mL === "number" ) || mL <= 0 ) mL = Infinity
this . _max = mL
if ( this . _length > this . _max ) trim ( this )
2014-12-02 18:45:21 +00:00
}
2018-05-29 18:03:59 +00:00
, get : function ( ) { return this . _max }
, enumerable : true
} )
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
// resize the cache when the lengthCalculator changes.
Object . defineProperty ( LRUCache . prototype , "lengthCalculator" ,
{ set : function ( lC ) {
if ( typeof lC !== "function" ) {
this . _lengthCalculator = naiveLength
this . _length = this . _itemCount
for ( var key in this . _cache ) {
this . _cache [ key ] . length = 1
}
} else {
this . _lengthCalculator = lC
this . _length = 0
for ( var key in this . _cache ) {
this . _cache [ key ] . length = this . _lengthCalculator ( this . _cache [ key ] . value )
this . _length += this . _cache [ key ] . length
}
}
if ( this . _length > this . _max ) trim ( this )
2014-12-02 18:45:21 +00:00
}
2018-05-29 18:03:59 +00:00
, get : function ( ) { return this . _lengthCalculator }
, enumerable : true
} )
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
Object . defineProperty ( LRUCache . prototype , "length" ,
{ get : function ( ) { return this . _length }
, enumerable : true
} )
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
Object . defineProperty ( LRUCache . prototype , "itemCount" ,
{ get : function ( ) { return this . _itemCount }
, enumerable : true
} )
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
LRUCache . prototype . forEach = function ( fn , thisp ) {
thisp = thisp || this
var i = 0 ;
for ( var k = this . _mru - 1 ; k >= 0 && i < this . _itemCount ; k -- ) if ( this . _lruList [ k ] ) {
i ++
var hit = this . _lruList [ k ]
if ( this . _maxAge && ( Date . now ( ) - hit . now > this . _maxAge ) ) {
del ( this , hit )
if ( ! this . _allowStale ) hit = undefined
}
if ( hit ) {
fn . call ( thisp , hit . value , hit . key , this )
2014-12-02 18:45:21 +00:00
}
}
2018-05-29 18:03:59 +00:00
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
LRUCache . prototype . keys = function ( ) {
var keys = new Array ( this . _itemCount )
var i = 0
for ( var k = this . _mru - 1 ; k >= 0 && i < this . _itemCount ; k -- ) if ( this . _lruList [ k ] ) {
var hit = this . _lruList [ k ]
keys [ i ++ ] = hit . key
2014-12-02 18:45:21 +00:00
}
2018-05-29 18:03:59 +00:00
return keys
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
LRUCache . prototype . values = function ( ) {
var values = new Array ( this . _itemCount )
var i = 0
for ( var k = this . _mru - 1 ; k >= 0 && i < this . _itemCount ; k -- ) if ( this . _lruList [ k ] ) {
var hit = this . _lruList [ k ]
values [ i ++ ] = hit . value
}
return values
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
LRUCache . prototype . reset = function ( ) {
if ( this . _dispose && this . _cache ) {
for ( var k in this . _cache ) {
this . _dispose ( k , this . _cache [ k ] . value )
2014-12-02 18:45:21 +00:00
}
2018-05-29 18:03:59 +00:00
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
this . _cache = Object . create ( null ) // hash of items by key
this . _lruList = Object . create ( null ) // list of items in order of use recency
this . _mru = 0 // most recently used
this . _lru = 0 // least recently used
this . _length = 0 // number of items in the list
this . _itemCount = 0
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
// Provided for debugging/dev purposes only. No promises whatsoever that
// this API stays stable.
LRUCache . prototype . dump = function ( ) {
return this . _cache
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
LRUCache . prototype . dumpLru = function ( ) {
return this . _lruList
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
LRUCache . prototype . set = function ( key , value ) {
if ( hOP ( this . _cache , key ) ) {
// dispose of the old one before overwriting
if ( this . _dispose ) this . _dispose ( key , this . _cache [ key ] . value )
if ( this . _maxAge ) this . _cache [ key ] . now = Date . now ( )
this . _cache [ key ] . value = value
this . get ( key )
return true
2014-12-02 18:45:21 +00:00
}
2018-05-29 18:03:59 +00:00
var len = this . _lengthCalculator ( value )
var age = this . _maxAge ? Date . now ( ) : 0
var hit = new Entry ( key , value , this . _mru ++ , len , age )
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
// oversized objects fall out of cache automatically.
if ( hit . length > this . _max ) {
if ( this . _dispose ) this . _dispose ( key , value )
return false
2014-12-02 18:45:21 +00:00
}
2018-05-29 18:03:59 +00:00
this . _length += hit . length
this . _lruList [ hit . lu ] = this . _cache [ key ] = hit
this . _itemCount ++
if ( this . _length > this . _max ) trim ( this )
return true
}
LRUCache . prototype . has = function ( key ) {
if ( ! hOP ( this . _cache , key ) ) return false
var hit = this . _cache [ key ]
if ( this . _maxAge && ( Date . now ( ) - hit . now > this . _maxAge ) ) {
return false
2014-12-02 18:45:21 +00:00
}
2018-05-29 18:03:59 +00:00
return true
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
LRUCache . prototype . get = function ( key ) {
return get ( this , key , true )
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
LRUCache . prototype . peek = function ( key ) {
return get ( this , key , false )
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
LRUCache . prototype . pop = function ( ) {
var hit = this . _lruList [ this . _lru ]
del ( this , hit )
return hit || null
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
LRUCache . prototype . del = function ( key ) {
del ( this , this . _cache [ key ] )
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
function get ( self , key , doUse ) {
var hit = self . _cache [ key ]
if ( hit ) {
if ( self . _maxAge && ( Date . now ( ) - hit . now > self . _maxAge ) ) {
del ( self , hit )
if ( ! self . _allowStale ) hit = undefined
} else {
if ( doUse ) use ( self , hit )
}
if ( hit ) hit = hit . value
2014-12-02 18:45:21 +00:00
}
2018-05-29 18:03:59 +00:00
return hit
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
function use ( self , hit ) {
shiftLU ( self , hit )
hit . lu = self . _mru ++
if ( self . _maxAge ) hit . now = Date . now ( )
self . _lruList [ hit . lu ] = hit
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
function trim ( self ) {
while ( self . _lru < self . _mru && self . _length > self . _max )
del ( self , self . _lruList [ self . _lru ] )
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
function shiftLU ( self , hit ) {
delete self . _lruList [ hit . lu ]
while ( self . _lru < self . _mru && ! self . _lruList [ self . _lru ] ) self . _lru ++
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
function del ( self , hit ) {
if ( hit ) {
if ( self . _dispose ) self . _dispose ( hit . key , hit . value )
self . _length -= hit . length
self . _itemCount --
delete self . _cache [ hit . key ]
shiftLU ( self , hit )
2014-12-02 18:45:21 +00:00
}
2018-05-29 18:03:59 +00:00
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
// classy, since V8 prefers predictable objects.
function Entry ( key , value , lu , length , now ) {
this . key = key
this . value = value
this . lu = lu
this . length = length
this . now = now
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
} ) ( )
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
} , { } ] , 11 : [ function ( require , module , exports ) {
; ( function ( require , exports , module , platform ) {
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
if ( module ) module . exports = minimatch
else exports . minimatch = minimatch
2015-05-31 15:18:20 +00:00
2015-06-29 16:29:46 +00:00
if ( ! require ) {
require = function ( id ) {
switch ( id ) {
case "sigmund" : return function sigmund ( obj ) {
return JSON . stringify ( obj )
}
case "path" : return { basename : function ( f ) {
f = f . split ( /[\/\\]/ )
var e = f . pop ( )
if ( ! e ) e = f . pop ( )
return e
} }
case "lru-cache" : return function LRUCache ( ) {
// not quite an LRU, but still space-limited.
var cache = { }
var cnt = 0
this . set = function ( k , v ) {
cnt ++
if ( cnt >= 100 ) cache = { }
cache [ k ] = v
}
this . get = function ( k ) { return cache [ k ] }
}
}
}
}
minimatch . Minimatch = Minimatch
var LRU = require ( "lru-cache" )
, cache = minimatch . cache = new LRU ( { max : 100 } )
, GLOBSTAR = minimatch . GLOBSTAR = Minimatch . GLOBSTAR = { }
, sigmund = require ( "sigmund" )
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
var path = require ( "path" )
// any single thing other than /
// don't need to escape / when using new RegExp()
, qmark = "[^/]"
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
// * => any number of characters
, star = qmark + "*?"
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
// ** when dots are allowed. Anything goes, except .. and .
// not (^ or / followed by one or two dots followed by $ or /),
// followed by anything, any number of times.
, twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?"
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
// not a ^ or / followed by a dot,
// followed by anything, any number of times.
, twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?"
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
// characters that need to be escaped in RegExp.
, reSpecials = charSet ( "().*{}+?[]^$\\!" )
2014-12-02 18:45:21 +00:00
// "abc" -> { a:true, b:true, c:true }
function charSet ( s ) {
2015-06-29 16:29:46 +00:00
return s . split ( "" ) . reduce ( function ( set , c ) {
2014-12-02 18:45:21 +00:00
set [ c ] = true
return set
} , { } )
}
// normalizes slashes.
var slashSplit = /\/+/
minimatch . filter = filter
function filter ( pattern , options ) {
options = options || { }
return function ( p , i , list ) {
return minimatch ( p , pattern , options )
}
}
function ext ( a , b ) {
a = a || { }
b = b || { }
var t = { }
Object . keys ( b ) . forEach ( function ( k ) {
t [ k ] = b [ k ]
} )
Object . keys ( a ) . forEach ( function ( k ) {
t [ k ] = a [ k ]
} )
return t
}
minimatch . defaults = function ( def ) {
if ( ! def || ! Object . keys ( def ) . length ) return minimatch
var orig = minimatch
var m = function minimatch ( p , pattern , options ) {
return orig . minimatch ( p , pattern , ext ( def , options ) )
}
m . Minimatch = function Minimatch ( pattern , options ) {
return new orig . Minimatch ( pattern , ext ( def , options ) )
}
return m
}
Minimatch . defaults = function ( def ) {
if ( ! def || ! Object . keys ( def ) . length ) return Minimatch
return minimatch . defaults ( def ) . Minimatch
}
2015-06-29 16:29:46 +00:00
2014-12-02 18:45:21 +00:00
function minimatch ( p , pattern , options ) {
2015-06-29 16:29:46 +00:00
if ( typeof pattern !== "string" ) {
throw new TypeError ( "glob pattern string required" )
2014-12-02 18:45:21 +00:00
}
if ( ! options ) options = { }
// shortcut: comments match nothing.
2015-06-29 16:29:46 +00:00
if ( ! options . nocomment && pattern . charAt ( 0 ) === "#" ) {
2014-12-02 18:45:21 +00:00
return false
}
// "" only matches ""
2015-06-29 16:29:46 +00:00
if ( pattern . trim ( ) === "" ) return p === ""
2014-12-02 18:45:21 +00:00
return new Minimatch ( pattern , options ) . match ( p )
}
function Minimatch ( pattern , options ) {
if ( ! ( this instanceof Minimatch ) ) {
2015-06-29 16:29:46 +00:00
return new Minimatch ( pattern , options , cache )
2014-12-02 18:45:21 +00:00
}
2015-06-29 16:29:46 +00:00
if ( typeof pattern !== "string" ) {
throw new TypeError ( "glob pattern string required" )
2014-12-02 18:45:21 +00:00
}
if ( ! options ) options = { }
pattern = pattern . trim ( )
2015-06-29 16:29:46 +00:00
// windows: need to use /, not \
// On other platforms, \ is a valid (albeit bad) filename char.
if ( platform === "win32" ) {
pattern = pattern . split ( "\\" ) . join ( "/" )
2014-12-02 18:45:21 +00:00
}
2015-06-29 16:29:46 +00:00
// lru storage.
// these things aren't particularly big, but walking down the string
// and turning it into a regexp can get pretty costly.
var cacheKey = pattern + "\n" + sigmund ( options )
var cached = minimatch . cache . get ( cacheKey )
if ( cached ) return cached
minimatch . cache . set ( cacheKey , this )
2014-12-02 18:45:21 +00:00
this . options = options
this . set = [ ]
this . pattern = pattern
this . regexp = null
this . negate = false
this . comment = false
this . empty = false
// make the set of regexps etc.
this . make ( )
}
2015-06-29 16:29:46 +00:00
Minimatch . prototype . debug = function ( ) { }
2014-12-02 18:45:21 +00:00
Minimatch . prototype . make = make
function make ( ) {
// don't do it more than once.
if ( this . _made ) return
var pattern = this . pattern
var options = this . options
// empty patterns and comments match nothing.
2015-06-29 16:29:46 +00:00
if ( ! options . nocomment && pattern . charAt ( 0 ) === "#" ) {
2014-12-02 18:45:21 +00:00
this . comment = true
return
}
if ( ! pattern ) {
this . empty = true
return
}
// step 1: figure out negation, etc.
this . parseNegate ( )
// step 2: expand braces
var set = this . globSet = this . braceExpand ( )
if ( options . debug ) this . debug = console . error
this . debug ( this . pattern , set )
// step 3: now we have a set, so turn each one into a series of path-portion
// matching patterns.
// These will be regexps, except in the case of "**", which is
// set to the GLOBSTAR object for globstar behavior,
// and will not contain any / characters
set = this . globParts = set . map ( function ( s ) {
return s . split ( slashSplit )
} )
this . debug ( this . pattern , set )
// glob --> regexps
set = set . map ( function ( s , si , set ) {
return s . map ( this . parse , this )
} , this )
this . debug ( this . pattern , set )
// filter out everything that didn't compile properly.
set = set . filter ( function ( s ) {
2015-06-29 16:29:46 +00:00
return - 1 === s . indexOf ( false )
2014-12-02 18:45:21 +00:00
} )
this . debug ( this . pattern , set )
this . set = set
}
Minimatch . prototype . parseNegate = parseNegate
function parseNegate ( ) {
var pattern = this . pattern
2015-06-29 16:29:46 +00:00
, negate = false
, options = this . options
, negateOffset = 0
2014-12-02 18:45:21 +00:00
if ( options . nonegate ) return
2015-06-29 16:29:46 +00:00
for ( var i = 0 , l = pattern . length
; i < l && pattern . charAt ( i ) === "!"
; i ++ ) {
2014-12-02 18:45:21 +00:00
negate = ! negate
2015-06-29 16:29:46 +00:00
negateOffset ++
2014-12-02 18:45:21 +00:00
}
if ( negateOffset ) this . pattern = pattern . substr ( negateOffset )
this . negate = negate
}
// Brace expansion:
// a{b,c}d -> abd acd
// a{b,}c -> abc ac
// a{0..3}d -> a0d a1d a2d a3d
// a{b,c{d,e}f}g -> abg acdfg acefg
// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
//
// Invalid sets are not expanded.
// a{2..}b -> a{2..}b
// a{b}c -> a{b}c
minimatch . braceExpand = function ( pattern , options ) {
2015-06-29 16:29:46 +00:00
return new Minimatch ( pattern , options ) . braceExpand ( )
2014-12-02 18:45:21 +00:00
}
Minimatch . prototype . braceExpand = braceExpand
2015-06-29 16:29:46 +00:00
function pad ( n , width , z ) {
z = z || '0' ;
n = n + '' ;
return n . length >= width ? n : new Array ( width - n . length + 1 ) . join ( z ) + n ;
}
2015-05-31 15:18:20 +00:00
2015-06-29 16:29:46 +00:00
function braceExpand ( pattern , options ) {
options = options || this . options
pattern = typeof pattern === "undefined"
2014-12-02 18:45:21 +00:00
? this . pattern : pattern
2015-06-29 16:29:46 +00:00
if ( typeof pattern === "undefined" ) {
throw new Error ( "undefined pattern" )
2014-12-02 18:45:21 +00:00
}
if ( options . nobrace ||
2015-06-29 16:29:46 +00:00
! pattern . match ( /\{.*\}/ ) ) {
2014-12-02 18:45:21 +00:00
// shortcut. no need to expand.
return [ pattern ]
}
2015-06-29 16:29:46 +00:00
var escaping = false
// examples and comments refer to this crazy pattern:
// a{b,c{d,e},{f,g}h}x{y,z}
// expected:
// abxy
// abxz
// acdxy
// acdxz
// acexy
// acexz
// afhxy
// afhxz
// aghxy
// aghxz
// everything before the first \{ is just a prefix.
// So, we pluck that off, and work with the rest,
// and then prepend it to everything we find.
if ( pattern . charAt ( 0 ) !== "{" ) {
this . debug ( pattern )
var prefix = null
for ( var i = 0 , l = pattern . length ; i < l ; i ++ ) {
var c = pattern . charAt ( i )
this . debug ( i , c )
if ( c === "\\" ) {
escaping = ! escaping
} else if ( c === "{" && ! escaping ) {
prefix = pattern . substr ( 0 , i )
break
}
}
// actually no sets, all { were escaped.
if ( prefix === null ) {
this . debug ( "no sets" )
return [ pattern ]
}
var tail = braceExpand . call ( this , pattern . substr ( i ) , options )
return tail . map ( function ( t ) {
return prefix + t
} )
}
// now we have something like:
// {b,c{d,e},{f,g}h}x{y,z}
// walk through the set, expanding each part, until
// the set ends. then, we'll expand the suffix.
// If the set only has a single member, then'll put the {} back
// first, handle numeric sets, since they're easier
var numset = pattern . match ( /^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/ )
if ( numset ) {
this . debug ( "numset" , numset [ 1 ] , numset [ 2 ] )
var suf = braceExpand . call ( this , pattern . substr ( numset [ 0 ] . length ) , options )
, start = + numset [ 1 ]
, needPadding = numset [ 1 ] [ 0 ] === '0'
, startWidth = numset [ 1 ] . length
, padded
, end = + numset [ 2 ]
, inc = start > end ? - 1 : 1
, set = [ ]
for ( var i = start ; i != ( end + inc ) ; i += inc ) {
padded = needPadding ? pad ( i , startWidth ) : i + ''
// append all the suffixes
for ( var ii = 0 , ll = suf . length ; ii < ll ; ii ++ ) {
set . push ( padded + suf [ ii ] )
}
}
return set
}
// ok, walk through the set
// We hope, somewhat optimistically, that there
// will be a } at the end.
// If the closing brace isn't found, then the pattern is
// interpreted as braceExpand("\\" + pattern) so that
// the leading \{ will be interpreted literally.
var i = 1 // skip the \{
, depth = 1
, set = [ ]
, member = ""
, sawEnd = false
, escaping = false
function addMember ( ) {
set . push ( member )
member = ""
}
this . debug ( "Entering for" )
FOR : for ( i = 1 , l = pattern . length ; i < l ; i ++ ) {
var c = pattern . charAt ( i )
this . debug ( "" , i , c )
if ( escaping ) {
escaping = false
member += "\\" + c
} else {
switch ( c ) {
case "\\" :
escaping = true
continue
case "{" :
depth ++
member += "{"
continue
case "}" :
depth --
// if this closes the actual set, then we're done
if ( depth === 0 ) {
addMember ( )
// pluck off the close-brace
i ++
break FOR
} else {
member += c
continue
}
case "," :
if ( depth === 1 ) {
addMember ( )
} else {
member += c
}
continue
default :
member += c
continue
} // switch
} // else
} // for
// now we've either finished the set, and the suffix is
// pattern.substr(i), or we have *not* closed the set,
// and need to escape the leading brace
if ( depth !== 0 ) {
this . debug ( "didn't close" , pattern )
return braceExpand . call ( this , "\\" + pattern , options )
}
// x{y,z} -> ["xy", "xz"]
this . debug ( "set" , set )
this . debug ( "suffix" , pattern . substr ( i ) )
var suf = braceExpand . call ( this , pattern . substr ( i ) , options )
// ["b", "c{d,e}","{f,g}h"] ->
// [["b"], ["cd", "ce"], ["fh", "gh"]]
var addBraces = set . length === 1
this . debug ( "set pre-expanded" , set )
set = set . map ( function ( p ) {
return braceExpand . call ( this , p , options )
} , this )
this . debug ( "set expanded" , set )
// [["b"], ["cd", "ce"], ["fh", "gh"]] ->
// ["b", "cd", "ce", "fh", "gh"]
set = set . reduce ( function ( l , r ) {
return l . concat ( r )
} )
if ( addBraces ) {
set = set . map ( function ( s ) {
return "{" + s + "}"
} )
}
// now attach the suffixes.
var ret = [ ]
for ( var i = 0 , l = set . length ; i < l ; i ++ ) {
for ( var ii = 0 , ll = suf . length ; ii < ll ; ii ++ ) {
ret . push ( set [ i ] + suf [ ii ] )
}
}
return ret
2014-12-02 18:45:21 +00:00
}
// parse a component of the expanded set.
// At this point, no pattern may contain "/" in it
// so we're going to return a 2d array, where each entry is the full
// pattern, split on '/', and then turned into a regular expression.
// A regexp is made at the end which joins each array with an
// escaped /, and another full one which joins each regexp with |.
//
// Following the lead of Bash 4.1, note that "**" only has special meaning
// when it is the *only* thing in a path portion. Otherwise, any series
// of * is equivalent to a single *. Globstar behavior is enabled by
// default, and can be disabled by setting options.noglobstar.
Minimatch . prototype . parse = parse
var SUBPARSE = { }
function parse ( pattern , isSub ) {
var options = this . options
// shortcuts
2015-06-29 16:29:46 +00:00
if ( ! options . noglobstar && pattern === "**" ) return GLOBSTAR
if ( pattern === "" ) return ""
var re = ""
, hasMagic = ! ! options . nocase
, escaping = false
// ? => one single character
, patternListStack = [ ]
, plType
, stateChar
, inClass = false
, reClassStart = - 1
, classStart = - 1
// . and .. never match anything that doesn't start with .,
// even when options.dot is set.
, patternStart = pattern . charAt ( 0 ) === "." ? "" // anything
// not (start or / followed by . or .. followed by / or end)
: options . dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))"
: "(?!\\.)"
, self = this
2014-12-02 18:45:21 +00:00
function clearStateChar ( ) {
if ( stateChar ) {
// we had some state-tracking character
// that wasn't consumed by this pass.
switch ( stateChar ) {
2015-06-29 16:29:46 +00:00
case "*" :
2014-12-02 18:45:21 +00:00
re += star
hasMagic = true
2015-06-29 16:29:46 +00:00
break
case "?" :
2014-12-02 18:45:21 +00:00
re += qmark
hasMagic = true
2015-06-29 16:29:46 +00:00
break
2014-12-02 18:45:21 +00:00
default :
2015-06-29 16:29:46 +00:00
re += "\\" + stateChar
break
2014-12-02 18:45:21 +00:00
}
self . debug ( 'clearStateChar %j %j' , stateChar , re )
stateChar = false
}
}
2015-06-29 16:29:46 +00:00
for ( var i = 0 , len = pattern . length , c
; ( i < len ) && ( c = pattern . charAt ( i ) )
; i ++ ) {
this . debug ( "%s\t%s %s %j" , pattern , i , re , c )
2014-12-02 18:45:21 +00:00
// skip over any that are escaped.
if ( escaping && reSpecials [ c ] ) {
2015-06-29 16:29:46 +00:00
re += "\\" + c
2014-12-02 18:45:21 +00:00
escaping = false
continue
}
2015-06-29 16:29:46 +00:00
SWITCH : switch ( c ) {
case "/" :
2014-12-02 18:45:21 +00:00
// completely not allowed, even escaped.
// Should already be path-split by now.
return false
2015-06-29 16:29:46 +00:00
case "\\" :
2014-12-02 18:45:21 +00:00
clearStateChar ( )
escaping = true
2015-06-29 16:29:46 +00:00
continue
2014-12-02 18:45:21 +00:00
// the various stateChar values
// for the "extglob" stuff.
2015-06-29 16:29:46 +00:00
case "?" :
case "*" :
case "+" :
case "@" :
case "!" :
this . debug ( "%s\t%s %s %j <-- stateChar" , pattern , i , re , c )
2014-12-02 18:45:21 +00:00
// all of those are literals inside a class, except that
// the glob [!a] means [^a] in regexp
if ( inClass ) {
this . debug ( ' in class' )
2015-06-29 16:29:46 +00:00
if ( c === "!" && i === classStart + 1 ) c = "^"
2014-12-02 18:45:21 +00:00
re += c
continue
}
// if we already have a stateChar, then it means
// that there was something like ** or +? in there.
// Handle the stateChar, then proceed with this one.
self . debug ( 'call clearStateChar %j' , stateChar )
clearStateChar ( )
stateChar = c
// if extglob is disabled, then +(asdf|foo) isn't a thing.
// just clear the statechar *now*, rather than even diving into
// the patternList stuff.
if ( options . noext ) clearStateChar ( )
2015-06-29 16:29:46 +00:00
continue
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
case "(" :
2014-12-02 18:45:21 +00:00
if ( inClass ) {
2015-06-29 16:29:46 +00:00
re += "("
2014-12-02 18:45:21 +00:00
continue
}
if ( ! stateChar ) {
2015-06-29 16:29:46 +00:00
re += "\\("
2014-12-02 18:45:21 +00:00
continue
}
plType = stateChar
2015-06-29 16:29:46 +00:00
patternListStack . push ( { type : plType
, start : i - 1
, reStart : re . length } )
2014-12-02 18:45:21 +00:00
// negation is (?:(?!js)[^/]*)
2015-06-29 16:29:46 +00:00
re += stateChar === "!" ? "(?:(?!" : "(?:"
2014-12-02 18:45:21 +00:00
this . debug ( 'plType %j %j' , stateChar , re )
stateChar = false
2015-06-29 16:29:46 +00:00
continue
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
case ")" :
2014-12-02 18:45:21 +00:00
if ( inClass || ! patternListStack . length ) {
2015-06-29 16:29:46 +00:00
re += "\\)"
2014-12-02 18:45:21 +00:00
continue
}
clearStateChar ( )
hasMagic = true
2015-06-29 16:29:46 +00:00
re += ")"
2014-12-02 18:45:21 +00:00
plType = patternListStack . pop ( ) . type
// negation is (?:(?!js)[^/]*)
// The others are (?:<pattern>)<type>
switch ( plType ) {
2015-06-29 16:29:46 +00:00
case "!" :
re += "[^/]*?)"
2015-05-31 15:18:20 +00:00
break
2015-06-29 16:29:46 +00:00
case "?" :
case "+" :
case "*" : re += plType
case "@" : break // the default anyway
2014-12-02 18:45:21 +00:00
}
2015-06-29 16:29:46 +00:00
continue
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
case "|" :
2014-12-02 18:45:21 +00:00
if ( inClass || ! patternListStack . length || escaping ) {
2015-06-29 16:29:46 +00:00
re += "\\|"
2014-12-02 18:45:21 +00:00
escaping = false
continue
}
clearStateChar ( )
2015-06-29 16:29:46 +00:00
re += "|"
continue
2014-12-02 18:45:21 +00:00
// these are mostly the same in regexp and glob
2015-06-29 16:29:46 +00:00
case "[" :
2014-12-02 18:45:21 +00:00
// swallow any state-tracking char before the [
clearStateChar ( )
if ( inClass ) {
2015-06-29 16:29:46 +00:00
re += "\\" + c
2014-12-02 18:45:21 +00:00
continue
}
inClass = true
classStart = i
reClassStart = re . length
re += c
2015-06-29 16:29:46 +00:00
continue
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
case "]" :
2014-12-02 18:45:21 +00:00
// a right bracket shall lose its special
// meaning and represent itself in
// a bracket expression if it occurs
// first in the list. -- POSIX.2 2.8.3.2
if ( i === classStart + 1 || ! inClass ) {
2015-06-29 16:29:46 +00:00
re += "\\" + c
2014-12-02 18:45:21 +00:00
escaping = false
continue
}
// finish up the class.
hasMagic = true
inClass = false
re += c
2015-06-29 16:29:46 +00:00
continue
2014-12-02 18:45:21 +00:00
default :
// swallow any state char that wasn't consumed
clearStateChar ( )
if ( escaping ) {
// no need
escaping = false
} else if ( reSpecials [ c ]
2015-06-29 16:29:46 +00:00
&& ! ( c === "^" && inClass ) ) {
re += "\\"
2014-12-02 18:45:21 +00:00
}
re += c
} // switch
} // for
2015-06-29 16:29:46 +00:00
2014-12-02 18:45:21 +00:00
// handle the case where we left a class open.
// "[abc" is valid, equivalent to "\[abc"
if ( inClass ) {
// split where the last [ was, and escape it
// this is a huge pita. We now have to re-walk
// the contents of the would-be class to re-translate
// any characters that were passed through as-is
2015-06-29 16:29:46 +00:00
var cs = pattern . substr ( classStart + 1 )
, sp = this . parse ( cs , SUBPARSE )
re = re . substr ( 0 , reClassStart ) + "\\[" + sp [ 0 ]
2014-12-02 18:45:21 +00:00
hasMagic = hasMagic || sp [ 1 ]
}
// handle the case where we had a +( thing at the *end*
// of the pattern.
// each pattern list stack adds 3 chars, and we need to go through
// and escape any | chars that were passed through as-is for the regexp.
// Go through and escape them, taking care not to double-escape any
// | chars that were already escaped.
2015-06-29 16:29:46 +00:00
var pl
while ( pl = patternListStack . pop ( ) ) {
2014-12-02 18:45:21 +00:00
var tail = re . slice ( pl . reStart + 3 )
// maybe some even number of \, then maybe 1 \, followed by a |
tail = tail . replace ( /((?:\\{2})*)(\\?)\|/g , function ( _ , $1 , $2 ) {
if ( ! $2 ) {
// the | isn't already escaped, so escape it.
2015-06-29 16:29:46 +00:00
$2 = "\\"
2014-12-02 18:45:21 +00:00
}
// need to escape all those slashes *again*, without escaping the
// one that we need for escaping the | character. As it works out,
// escaping an even number of slashes can be done by simply repeating
// it exactly after itself. That's why this trick works.
//
// I am sorry that you have to see this.
2015-06-29 16:29:46 +00:00
return $1 + $1 + $2 + "|"
2014-12-02 18:45:21 +00:00
} )
2015-06-29 16:29:46 +00:00
this . debug ( "tail=%j\n %s" , tail , tail )
var t = pl . type === "*" ? star
: pl . type === "?" ? qmark
: "\\" + pl . type
2014-12-02 18:45:21 +00:00
hasMagic = true
2015-06-29 16:29:46 +00:00
re = re . slice ( 0 , pl . reStart )
+ t + "\\("
+ tail
2014-12-02 18:45:21 +00:00
}
// handle trailing things that only matter at the very end.
clearStateChar ( )
if ( escaping ) {
// trailing \\
2015-06-29 16:29:46 +00:00
re += "\\\\"
2014-12-02 18:45:21 +00:00
}
// only need to apply the nodot start if the re starts with
// something that could conceivably capture a dot
var addPatternStart = false
switch ( re . charAt ( 0 ) ) {
2015-06-29 16:29:46 +00:00
case "." :
case "[" :
case "(" : addPatternStart = true
2014-12-02 18:45:21 +00:00
}
// if the re is not "" at this point, then we need to make sure
// it doesn't match against an empty path part.
// Otherwise a/* will match a/, which it should not.
2015-06-29 16:29:46 +00:00
if ( re !== "" && hasMagic ) re = "(?=.)" + re
2014-12-02 18:45:21 +00:00
if ( addPatternStart ) re = patternStart + re
// parsing just a piece of a larger pattern.
if ( isSub === SUBPARSE ) {
2015-06-29 16:29:46 +00:00
return [ re , hasMagic ]
2014-12-02 18:45:21 +00:00
}
// skip the regexp for non-magical patterns
// unescape anything in it, though, so that it'll be
// an exact match against a file etc.
if ( ! hasMagic ) {
return globUnescape ( pattern )
}
2015-06-29 16:29:46 +00:00
var flags = options . nocase ? "i" : ""
, regExp = new RegExp ( "^" + re + "$" , flags )
2014-12-02 18:45:21 +00:00
regExp . _glob = pattern
regExp . _src = re
return regExp
}
minimatch . makeRe = function ( pattern , options ) {
return new Minimatch ( pattern , options || { } ) . makeRe ( )
}
Minimatch . prototype . makeRe = makeRe
function makeRe ( ) {
if ( this . regexp || this . regexp === false ) return this . regexp
// at this point, this.set is a 2d array of partial
// pattern strings, or "**".
//
// It's better to use .match(). This function shouldn't
// be used, really, but it's pretty convenient sometimes,
// when you just want to work with a regex.
var set = this . set
2015-06-29 16:29:46 +00:00
if ( ! set . length ) return this . regexp = false
2014-12-02 18:45:21 +00:00
var options = this . options
var twoStar = options . noglobstar ? star
2015-06-29 16:29:46 +00:00
: options . dot ? twoStarDot
: twoStarNoDot
, flags = options . nocase ? "i" : ""
2014-12-02 18:45:21 +00:00
var re = set . map ( function ( pattern ) {
return pattern . map ( function ( p ) {
return ( p === GLOBSTAR ) ? twoStar
2015-06-29 16:29:46 +00:00
: ( typeof p === "string" ) ? regExpEscape ( p )
: p . _src
} ) . join ( "\\\/" )
} ) . join ( "|" )
2014-12-02 18:45:21 +00:00
// must match entire pattern
// ending in a * or ** will make it less strict.
2015-06-29 16:29:46 +00:00
re = "^(?:" + re + ")$"
2014-12-02 18:45:21 +00:00
// can match anything, as long as it's not this.
2015-06-29 16:29:46 +00:00
if ( this . negate ) re = "^(?!" + re + ").*$"
2014-12-02 18:45:21 +00:00
try {
2015-06-29 16:29:46 +00:00
return this . regexp = new RegExp ( re , flags )
2014-12-02 18:45:21 +00:00
} catch ( ex ) {
2015-06-29 16:29:46 +00:00
return this . regexp = false
2014-12-02 18:45:21 +00:00
}
}
minimatch . match = function ( list , pattern , options ) {
options = options || { }
var mm = new Minimatch ( pattern , options )
list = list . filter ( function ( f ) {
return mm . match ( f )
} )
if ( mm . options . nonull && ! list . length ) {
list . push ( pattern )
}
return list
}
2014-06-09 14:40:50 +00:00
2014-12-02 18:45:21 +00:00
Minimatch . prototype . match = match
function match ( f , partial ) {
2015-06-29 16:29:46 +00:00
this . debug ( "match" , f , this . pattern )
2014-12-02 18:45:21 +00:00
// short-circuit in the case of busted things.
// comments, etc.
if ( this . comment ) return false
2015-06-29 16:29:46 +00:00
if ( this . empty ) return f === ""
2014-06-09 14:40:50 +00:00
2015-06-29 16:29:46 +00:00
if ( f === "/" && partial ) return true
2014-12-02 18:45:21 +00:00
var options = this . options
// windows: need to use /, not \
2015-06-29 16:29:46 +00:00
// On other platforms, \ is a valid (albeit bad) filename char.
if ( platform === "win32" ) {
f = f . split ( "\\" ) . join ( "/" )
2014-12-02 18:45:21 +00:00
}
// treat the test path as a set of pathparts.
f = f . split ( slashSplit )
2015-06-29 16:29:46 +00:00
this . debug ( this . pattern , "split" , f )
2014-12-02 18:45:21 +00:00
// just ONE of the pattern sets in this.set needs to match
// in order for it to be valid. If negating, then just one
// match means that we have failed.
// Either way, return on the first hit.
var set = this . set
2015-06-29 16:29:46 +00:00
this . debug ( this . pattern , "set" , set )
2014-12-02 18:45:21 +00:00
// Find the basename of the path by looking for the last non-empty segment
2015-06-29 16:29:46 +00:00
var filename ;
for ( var i = f . length - 1 ; i >= 0 ; i -- ) {
2014-12-02 18:45:21 +00:00
filename = f [ i ]
if ( filename ) break
}
2015-06-29 16:29:46 +00:00
for ( var i = 0 , l = set . length ; i < l ; i ++ ) {
var pattern = set [ i ] , file = f
2014-12-02 18:45:21 +00:00
if ( options . matchBase && pattern . length === 1 ) {
file = [ filename ]
}
var hit = this . matchOne ( file , pattern , partial )
if ( hit ) {
if ( options . flipNegate ) return true
return ! this . negate
}
}
// didn't get any hits. this is success if it's a negative
// pattern, failure otherwise.
if ( options . flipNegate ) return false
return this . negate
}
// set partial to true to test if, for example,
// "/a/b" matches the start of "/*/b/*/d"
// Partial means, if you run out of file before you run
// out of pattern, then that's fine, as long as all
// the parts match.
Minimatch . prototype . matchOne = function ( file , pattern , partial ) {
var options = this . options
2015-06-29 16:29:46 +00:00
this . debug ( "matchOne" ,
{ "this" : this
, file : file
, pattern : pattern } )
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
this . debug ( "matchOne" , file . length , pattern . length )
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
for ( var fi = 0
, pi = 0
, fl = file . length
, pl = pattern . length
2014-12-02 18:45:21 +00:00
; ( fi < fl ) && ( pi < pl )
2015-06-29 16:29:46 +00:00
; fi ++ , pi ++ ) {
this . debug ( "matchOne loop" )
2014-12-02 18:45:21 +00:00
var p = pattern [ pi ]
2015-06-29 16:29:46 +00:00
, f = file [ fi ]
2014-12-02 18:45:21 +00:00
this . debug ( pattern , p , f )
// should be impossible.
// some invalid regexp stuff in the set.
if ( p === false ) return false
if ( p === GLOBSTAR ) {
this . debug ( 'GLOBSTAR' , [ pattern , p , f ] )
// "**"
// a/**/b/**/c would match the following:
// a/b/x/y/z/c
// a/x/y/z/b/c
// a/b/x/b/x/c
// a/b/c
// To do this, take the rest of the pattern after
// the **, and see if it would match the file remainder.
// If so, return success.
// If not, the ** "swallows" a segment, and try again.
// This is recursively awful.
//
// a/**/b/**/c matching a/b/x/y/z/c
// - a matches a
// - doublestar
// - matchOne(b/x/y/z/c, b/**/c)
// - b matches b
// - doublestar
// - matchOne(x/y/z/c, c) -> no
// - matchOne(y/z/c, c) -> no
// - matchOne(z/c, c) -> no
// - matchOne(c, c) yes, hit
var fr = fi
2015-06-29 16:29:46 +00:00
, pr = pi + 1
2014-12-02 18:45:21 +00:00
if ( pr === pl ) {
this . debug ( '** at the end' )
// a ** at the end will just swallow the rest.
// We have found a match.
// however, it will not swallow /.x, unless
// options.dot is set.
// . and .. are *never* matched by **, for explosively
// exponential reasons.
2015-06-29 16:29:46 +00:00
for ( ; fi < fl ; fi ++ ) {
if ( file [ fi ] === "." || file [ fi ] === ".." ||
( ! options . dot && file [ fi ] . charAt ( 0 ) === "." ) ) return false
2014-12-02 18:45:21 +00:00
}
return true
}
// ok, let's see if we can swallow whatever we can.
2015-06-29 16:29:46 +00:00
WHILE : while ( fr < fl ) {
2014-12-02 18:45:21 +00:00
var swallowee = file [ fr ]
2015-06-29 16:29:46 +00:00
this . debug ( '\nglobstar while' ,
file , fr , pattern , pr , swallowee )
2014-12-02 18:45:21 +00:00
// XXX remove this slice. Just pass the start index.
if ( this . matchOne ( file . slice ( fr ) , pattern . slice ( pr ) , partial ) ) {
this . debug ( 'globstar found match!' , fr , fl , swallowee )
// found a match.
return true
} else {
// can't swallow "." or ".." ever.
// can only swallow ".foo" when explicitly asked.
2015-06-29 16:29:46 +00:00
if ( swallowee === "." || swallowee === ".." ||
( ! options . dot && swallowee . charAt ( 0 ) === "." ) ) {
this . debug ( "dot detected!" , file , fr , pattern , pr )
break WHILE
2014-12-02 18:45:21 +00:00
}
// ** swallows a segment, and continue.
this . debug ( 'globstar swallow a segment, and continue' )
2015-06-29 16:29:46 +00:00
fr ++
2014-12-02 18:45:21 +00:00
}
}
// no match was found.
// However, in partial mode, we can't say this is necessarily over.
// If there's more *pattern* left, then
if ( partial ) {
// ran out of file
2015-06-29 16:29:46 +00:00
this . debug ( "\n>>> no match, partial?" , file , fr , pattern , pr )
2014-12-02 18:45:21 +00:00
if ( fr === fl ) return true
}
return false
2014-06-09 14:40:50 +00:00
}
2014-12-02 18:45:21 +00:00
// something other than **
// non-magic patterns just have to match exactly
// patterns with magic have been turned into regexps.
var hit
2015-06-29 16:29:46 +00:00
if ( typeof p === "string" ) {
2014-12-02 18:45:21 +00:00
if ( options . nocase ) {
hit = f . toLowerCase ( ) === p . toLowerCase ( )
} else {
hit = f === p
}
2015-06-29 16:29:46 +00:00
this . debug ( "string match" , p , f , hit )
2014-12-02 18:45:21 +00:00
} else {
hit = f . match ( p )
2015-06-29 16:29:46 +00:00
this . debug ( "pattern match" , p , f , hit )
2014-12-02 18:45:21 +00:00
}
2014-06-09 14:40:50 +00:00
2014-12-02 18:45:21 +00:00
if ( ! hit ) return false
}
// Note: ending in / means that we'll get a final ""
// at the end of the pattern. This can only match a
// corresponding "" at the end of the file.
// If the file ends in /, then it can only match a
// a pattern that ends in /, unless the pattern just
// doesn't have any more for it. But, a/b/ should *not*
// match "a/b/*", even though "" matches against the
// [^/]*? pattern, except in partial mode, where it might
// simply not be reached yet.
// However, a/b/ should still satisfy a/*
// now either we fell off the end of the pattern, or we're done.
if ( fi === fl && pi === pl ) {
// ran out of pattern and filename at the same time.
// an exact hit!
return true
} else if ( fi === fl ) {
// ran out of file, but still had pattern left.
// this is ok if we're doing the match as part of
// a glob fs traversal.
return partial
} else if ( pi === pl ) {
// ran out of pattern, still have file left.
// this is only acceptable if we're on the very last
// empty segment of a file with a trailing slash.
// a/* should match a/b/
2015-06-29 16:29:46 +00:00
var emptyFileEnd = ( fi === fl - 1 ) && ( file [ fi ] === "" )
2014-12-02 18:45:21 +00:00
return emptyFileEnd
}
// should be unreachable.
2015-06-29 16:29:46 +00:00
throw new Error ( "wtf?" )
2014-12-02 18:45:21 +00:00
}
2015-06-29 16:29:46 +00:00
2014-12-02 18:45:21 +00:00
// replace stuff like \* with *
function globUnescape ( s ) {
2015-06-29 16:29:46 +00:00
return s . replace ( /\\(.)/g , "$1" )
2014-12-02 18:45:21 +00:00
}
2015-06-29 16:29:46 +00:00
2014-12-02 18:45:21 +00:00
function regExpEscape ( s ) {
2015-06-29 16:29:46 +00:00
return s . replace ( /[-[\]{}()*+?.,\\^$|#\s]/g , "\\$&" )
2014-12-02 18:45:21 +00:00
}
2015-06-29 16:29:46 +00:00
} ) ( typeof require === "function" ? require : null ,
this ,
typeof module === "object" ? module : null ,
typeof process === "object" ? process . platform : "win32"
)
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
} , { "lru-cache" : 10 , "path" : 12 , "sigmund" : 13 } ] , 12 : [ function ( require , module , exports ) {
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
// resolves . and .. elements in a path array with directory names there
// must be no slashes, empty elements, or device names (c:\) in the array
// (so also no leading and trailing slashes - it does not distinguish
// relative and absolute paths)
function normalizeArray ( parts , allowAboveRoot ) {
// if the path tries to go above the root, `up` ends up > 0
var up = 0 ;
for ( var i = parts . length - 1 ; i >= 0 ; i -- ) {
var last = parts [ i ] ;
if ( last === '.' ) {
parts . splice ( i , 1 ) ;
} else if ( last === '..' ) {
parts . splice ( i , 1 ) ;
up ++ ;
} else if ( up ) {
parts . splice ( i , 1 ) ;
up -- ;
}
}
2014-06-09 14:40:50 +00:00
2018-05-29 18:03:59 +00:00
// if the path is allowed to go above the root, restore leading ..s
if ( allowAboveRoot ) {
for ( ; up -- ; up ) {
parts . unshift ( '..' ) ;
}
}
2014-06-09 14:40:50 +00:00
2018-05-29 18:03:59 +00:00
return parts ;
2015-06-29 16:29:46 +00:00
}
2014-06-09 14:40:50 +00:00
2018-05-29 18:03:59 +00:00
// Split a filename into [root, dir, basename, ext], unix version
// 'root' is just a slash, or nothing.
var splitPathRe =
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/ ;
var splitPath = function ( filename ) {
return splitPathRe . exec ( filename ) . slice ( 1 ) ;
} ;
2014-06-09 14:40:50 +00:00
2018-05-29 18:03:59 +00:00
// path.resolve([from ...], to)
// posix version
exports . resolve = function ( ) {
var resolvedPath = '' ,
resolvedAbsolute = false ;
2015-06-29 16:29:46 +00:00
2018-05-29 18:03:59 +00:00
for ( var i = arguments . length - 1 ; i >= - 1 && ! resolvedAbsolute ; i -- ) {
var path = ( i >= 0 ) ? arguments [ i ] : process . cwd ( ) ;
// Skip empty and invalid entries
if ( typeof path !== 'string' ) {
throw new TypeError ( 'Arguments to path.resolve must be strings' ) ;
} else if ( ! path ) {
continue ;
2015-06-29 16:29:46 +00:00
}
2018-05-29 18:03:59 +00:00
resolvedPath = path + '/' + resolvedPath ;
resolvedAbsolute = path . charAt ( 0 ) === '/' ;
}
2014-06-09 14:40:50 +00:00
2018-05-29 18:03:59 +00:00
// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
// Normalize the path
resolvedPath = normalizeArray ( filter ( resolvedPath . split ( '/' ) , function ( p ) {
return ! ! p ;
} ) , ! resolvedAbsolute ) . join ( '/' ) ;
2015-06-29 16:29:46 +00:00
2018-05-29 18:03:59 +00:00
return ( ( resolvedAbsolute ? '/' : '' ) + resolvedPath ) || '.' ;
} ;
2015-07-16 21:56:12 +00:00
2018-05-29 18:03:59 +00:00
// path.normalize(path)
// posix version
exports . normalize = function ( path ) {
var isAbsolute = exports . isAbsolute ( path ) ,
trailingSlash = substr ( path , - 1 ) === '/' ;
2014-06-09 14:40:50 +00:00
2018-05-29 18:03:59 +00:00
// Normalize the path
path = normalizeArray ( filter ( path . split ( '/' ) , function ( p ) {
return ! ! p ;
} ) , ! isAbsolute ) . join ( '/' ) ;
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
if ( ! path && ! isAbsolute ) {
path = '.' ;
2015-06-29 16:29:46 +00:00
}
2018-05-29 18:03:59 +00:00
if ( path && trailingSlash ) {
path += '/' ;
2015-06-29 16:29:46 +00:00
}
2018-05-29 18:03:59 +00:00
return ( isAbsolute ? '/' : '' ) + path ;
} ;
2015-06-29 16:29:46 +00:00
2018-05-29 18:03:59 +00:00
// posix version
exports . isAbsolute = function ( path ) {
return path . charAt ( 0 ) === '/' ;
} ;
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
// posix version
exports . join = function ( ) {
var paths = Array . prototype . slice . call ( arguments , 0 ) ;
return exports . normalize ( filter ( paths , function ( p , index ) {
if ( typeof p !== 'string' ) {
throw new TypeError ( 'Arguments to path.join must be strings' ) ;
}
return p ;
} ) . join ( '/' ) ) ;
} ;
2015-07-16 21:56:12 +00:00
2018-05-29 18:03:59 +00:00
// path.relative(from, to)
// posix version
exports . relative = function ( from , to ) {
from = exports . resolve ( from ) . substr ( 1 ) ;
to = exports . resolve ( to ) . substr ( 1 ) ;
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
function trim ( arr ) {
var start = 0 ;
for ( ; start < arr . length ; start ++ ) {
if ( arr [ start ] !== '' ) break ;
}
2015-06-29 16:29:46 +00:00
2018-05-29 18:03:59 +00:00
var end = arr . length - 1 ;
for ( ; end >= 0 ; end -- ) {
if ( arr [ end ] !== '' ) break ;
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
if ( start > end ) return [ ] ;
return arr . slice ( start , end - start + 1 ) ;
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
var fromParts = trim ( from . split ( '/' ) ) ;
var toParts = trim ( to . split ( '/' ) ) ;
2015-07-16 21:56:12 +00:00
2018-05-29 18:03:59 +00:00
var length = Math . min ( fromParts . length , toParts . length ) ;
var samePartsLength = length ;
for ( var i = 0 ; i < length ; i ++ ) {
if ( fromParts [ i ] !== toParts [ i ] ) {
samePartsLength = i ;
break ;
}
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
var outputParts = [ ] ;
for ( var i = samePartsLength ; i < fromParts . length ; i ++ ) {
outputParts . push ( '..' ) ;
2015-06-29 16:29:46 +00:00
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
outputParts = outputParts . concat ( toParts . slice ( samePartsLength ) ) ;
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
return outputParts . join ( '/' ) ;
} ;
2015-06-29 16:29:46 +00:00
2018-05-29 18:03:59 +00:00
exports . sep = '/' ;
exports . delimiter = ':' ;
2015-06-29 16:29:46 +00:00
2018-05-29 18:03:59 +00:00
exports . dirname = function ( path ) {
var result = splitPath ( path ) ,
root = result [ 0 ] ,
dir = result [ 1 ] ;
2015-06-29 16:29:46 +00:00
2018-05-29 18:03:59 +00:00
if ( ! root && ! dir ) {
// No dirname whatsoever
return '.' ;
2015-05-31 15:18:20 +00:00
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
if ( dir ) {
// It has a dirname, strip trailing slash
dir = dir . substr ( 0 , dir . length - 1 ) ;
2015-07-16 21:56:12 +00:00
}
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
return root + dir ;
} ;
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
exports . basename = function ( path , ext ) {
var f = splitPath ( path ) [ 2 ] ;
// TODO: make this comparison case-insensitive on windows?
if ( ext && f . substr ( - 1 * ext . length ) === ext ) {
f = f . substr ( 0 , f . length - ext . length ) ;
2014-12-02 18:45:21 +00:00
}
2018-05-29 18:03:59 +00:00
return f ;
} ;
2014-12-02 18:45:21 +00:00
2018-05-29 18:03:59 +00:00
exports . extname = function ( path ) {
return splitPath ( path ) [ 3 ] ;
} ;
function filter ( xs , f ) {
if ( xs . filter ) return xs . filter ( f ) ;
var res = [ ] ;
for ( var i = 0 ; i < xs . length ; i ++ ) {
if ( f ( xs [ i ] , i , xs ) ) res . push ( xs [ i ] ) ;
}
return res ;
2014-12-02 18:45:21 +00:00
}
2018-05-29 18:03:59 +00:00
// String.prototype.substr - negative index don't work in IE8
var substr = 'ab' . substr ( - 1 ) === 'b'
? function ( str , start , len ) { return str . substr ( start , len ) }
: function ( str , start , len ) {
if ( start < 0 ) start = str . length + start ;
return str . substr ( start , len ) ;
}
;
2015-06-29 16:29:46 +00:00
} , { } ] , 13 : [ function ( require , module , exports ) {
module . exports = sigmund
function sigmund ( subject , maxSessions ) {
maxSessions = maxSessions || 10 ;
var notes = [ ] ;
var analysis = '' ;
var RE = RegExp ;
function psychoAnalyze ( subject , session ) {
if ( session > maxSessions ) return ;
if ( typeof subject === 'function' ||
typeof subject === 'undefined' ) {
return ;
}
if ( typeof subject !== 'object' || ! subject ||
( subject instanceof RE ) ) {
analysis += subject ;
return ;
}
if ( notes . indexOf ( subject ) !== - 1 || session === maxSessions ) return ;
notes . push ( subject ) ;
analysis += '{' ;
Object . keys ( subject ) . forEach ( function ( issue , _ , _ _ ) {
// pseudo-private values. skip those.
if ( issue . charAt ( 0 ) === '_' ) return ;
var to = typeof subject [ issue ] ;
if ( to === 'function' || to === 'undefined' ) return ;
analysis += issue ;
psychoAnalyze ( subject [ issue ] , session + 1 ) ;
} ) ;
2014-12-02 18:45:21 +00:00
}
2015-06-29 16:29:46 +00:00
psychoAnalyze ( subject , 0 ) ;
return analysis ;
}
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
// vim: set softtabstop=4 shiftwidth=4:
2014-12-02 18:45:21 +00:00
2015-06-29 16:29:46 +00:00
} , { } ] , 14 : [ function ( require , module , exports ) {
2014-08-17 05:56:03 +00:00
( function ( Buffer ) {
function FilerBuffer ( subject , encoding , nonZero ) {
2018-06-28 17:35:20 +00:00
=== === =
function asciiSlice ( buf , start , end ) {
var ret = ''
end = Math . min ( buf . length , end )
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
for ( var i = start ; i < end ; ++ i ) {
ret += String . fromCharCode ( buf [ i ] & 0x7F )
2014-08-17 05:56:03 +00:00
}
2018-06-28 17:35:20 +00:00
return ret
}
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
function latin1Slice ( buf , start , end ) {
var ret = ''
end = Math . min ( buf . length , end )
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
for ( var i = start ; i < end ; ++ i ) {
ret += String . fromCharCode ( buf [ i ] )
2014-08-17 05:56:03 +00:00
}
2018-06-28 17:35:20 +00:00
return ret
}
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
} ) . call ( this , require ( "buffer" ) . Buffer )
2018-05-29 18:03:59 +00:00
} , { "buffer" : 7 } ] , 15 : [ function ( require , module , exports ) {
2014-05-27 18:44:30 +00:00
var O _READ = 'READ' ;
var O _WRITE = 'WRITE' ;
var O _CREATE = 'CREATE' ;
var O _EXCLUSIVE = 'EXCLUSIVE' ;
var O _TRUNCATE = 'TRUNCATE' ;
var O _APPEND = 'APPEND' ;
var XATTR _CREATE = 'CREATE' ;
var XATTR _REPLACE = 'REPLACE' ;
2018-06-28 17:35:20 +00:00
=== === =
function hexSlice ( buf , start , end ) {
var len = buf . length
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( ! start || start < 0 ) start = 0
if ( ! end || end < 0 || end > len ) end = len
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var out = ''
for ( var i = start ; i < end ; ++ i ) {
out += toHex ( buf [ i ] )
}
return out
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function utf16leSlice ( buf , start , end ) {
var bytes = buf . slice ( start , end )
var res = ''
for ( var i = 0 ; i < bytes . length ; i += 2 ) {
res += String . fromCharCode ( bytes [ i ] + bytes [ i + 1 ] * 256 )
}
return res
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
WSQL _VERSION : "1" ,
WSQL _SIZE : 5 * 1024 * 1024 ,
WSQL _DESC : "FileSystem Storage" ,
2018-05-29 18:03:59 +00:00
NODE _TYPE _FILE : 'FILE' ,
NODE _TYPE _DIRECTORY : 'DIRECTORY' ,
NODE _TYPE _SYMBOLIC _LINK : 'SYMLINK' ,
NODE _TYPE _META : 'META' ,
2014-05-27 18:44:30 +00:00
2018-05-29 18:03:59 +00:00
S _IFREG : 0x8000 ,
S _IFDIR : 0x4000 ,
S _IFLNK : 0xA000 ,
DEFAULT _DIR _PERMISSIONS : 0x1ED , // 755
DEFAULT _FILE _PERMISSIONS : 0x1A4 , // 644
FULL _READ _WRITE _EXEC _PERMISSIONS : 0x1FF , // 777
READ _WRITE _PERMISSIONS : 0x1B6 , /// 666
2014-05-27 18:44:30 +00:00
SYMLOOP _MAX : 10 ,
2018-06-28 17:35:20 +00:00
=== === =
Buffer . prototype . slice = function slice ( start , end ) {
var len = this . length
start = ~ ~ start
end = end === undefined ? len : ~ ~ end
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( start < 0 ) {
start += len
if ( start < 0 ) start = 0
} else if ( start > len ) {
start = len
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( end < 0 ) {
end += len
if ( end < 0 ) end = 0
} else if ( end > len ) {
end = len
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( end < start ) end = start
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var newBuf
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
newBuf = this . subarray ( start , end )
newBuf . _ _proto _ _ = Buffer . prototype
} else {
var sliceLen = end - start
newBuf = new Buffer ( sliceLen , undefined )
for ( var i = 0 ; i < sliceLen ; ++ i ) {
newBuf [ i ] = this [ i + start ]
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
return newBuf
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
/ *
* Need to make sure that buffer isn ' t trying to write out of bounds .
* /
function checkOffset ( offset , ext , length ) {
if ( ( offset % 1 ) !== 0 || offset < 0 ) throw new RangeError ( 'offset is not uint' )
if ( offset + ext > length ) throw new RangeError ( 'Trying to access beyond buffer length' )
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Buffer . prototype . readUIntLE = function readUIntLE ( offset , byteLength , noAssert ) {
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) checkOffset ( offset , byteLength , this . length )
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var val = this [ offset ]
var mul = 1
var i = 0
while ( ++ i < byteLength && ( mul *= 0x100 ) ) {
val += this [ offset + i ] * mul
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
return val
}
Buffer . prototype . readUIntBE = function readUIntBE ( offset , byteLength , noAssert ) {
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) {
checkOffset ( offset , byteLength , this . length )
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
ENVIRONMENT : {
TMP : '/tmp' ,
PATH : ''
2018-05-29 18:03:59 +00:00
} ,
// Duplicate Node's fs.constants
fsConstants : {
O _RDONLY : 0 ,
O _WRONLY : 1 ,
O _RDWR : 2 ,
S _IFMT : 61440 ,
S _IFREG : 32768 ,
S _IFDIR : 16384 ,
S _IFCHR : 8192 ,
S _IFBLK : 24576 ,
S _IFIFO : 4096 ,
S _IFLNK : 40960 ,
S _IFSOCK : 49152 ,
O _CREAT : 512 ,
O _EXCL : 2048 ,
O _NOCTTY : 131072 ,
O _TRUNC : 1024 ,
O _APPEND : 8 ,
O _DIRECTORY : 1048576 ,
O _NOFOLLOW : 256 ,
O _SYNC : 128 ,
O _DSYNC : 4194304 ,
O _SYMLINK : 2097152 ,
O _NONBLOCK : 4 ,
S _IRWXU : 448 ,
S _IRUSR : 256 ,
S _IWUSR : 128 ,
S _IXUSR : 64 ,
S _IRWXG : 56 ,
S _IRGRP : 32 ,
S _IWGRP : 16 ,
S _IXGRP : 8 ,
S _IRWXO : 7 ,
S _IROTH : 4 ,
S _IWOTH : 2 ,
S _IXOTH : 1 ,
F _OK : 0 ,
R _OK : 4 ,
W _OK : 2 ,
X _OK : 1 ,
UV _FS _COPYFILE _EXCL : 1 ,
COPYFILE _EXCL : 1
2018-06-28 17:35:20 +00:00
=== === =
var val = this [ offset + -- byteLength ]
var mul = 1
while ( byteLength > 0 && ( mul *= 0x100 ) ) {
val += this [ offset + -- byteLength ] * mul
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
} , { } ] , 16 : [ function ( require , module , exports ) {
2018-05-29 18:03:59 +00:00
var NODE _TYPE _FILE = require ( './constants.js' ) . NODE _TYPE _FILE ;
2014-05-27 18:44:30 +00:00
module . exports = function DirectoryEntry ( id , type ) {
this . id = id ;
2018-05-29 18:03:59 +00:00
this . type = type || NODE _TYPE _FILE ;
2014-05-27 18:44:30 +00:00
} ;
2018-06-28 17:35:20 +00:00
=== === =
return val
2014-06-09 14:40:50 +00:00
}
2018-06-28 17:35:20 +00:00
Buffer . prototype . readUInt8 = function readUInt8 ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 1 , this . length )
return this [ offset ]
2014-06-09 14:40:50 +00:00
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-06-09 14:40:50 +00:00
2018-06-28 17:35:20 +00:00
Buffer . prototype . readUInt16LE = function readUInt16LE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 2 , this . length )
return this [ offset ] | ( this [ offset + 1 ] << 8 )
}
Buffer . prototype . readUInt16BE = function readUInt16BE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 2 , this . length )
return ( this [ offset ] << 8 ) | this [ offset + 1 ]
}
Buffer . prototype . readUInt32LE = function readUInt32LE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
2014-06-09 14:40:50 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
} ) . call ( this , require ( "buffer" ) . Buffer )
2018-05-29 18:03:59 +00:00
} , { "buffer" : 7 } ] , 18 : [ function ( require , module , exports ) {
2014-05-27 18:44:30 +00:00
var errors = { } ;
[
/ * *
2014-08-20 18:48:40 +00:00
* node . js errors - we only use some of these , add as needed .
2014-05-27 18:44:30 +00:00
* /
2014-08-20 18:48:40 +00:00
//'-1:UNKNOWN:unknown error',
//'0:OK:success',
//'1:EOF:end of file',
//'2:EADDRINFO:getaddrinfo error',
//'3:EACCES:permission denied',
//'4:EAGAIN:resource temporarily unavailable',
//'5:EADDRINUSE:address already in use',
//'6:EADDRNOTAVAIL:address not available',
//'7:EAFNOSUPPORT:address family not supported',
//'8:EALREADY:connection already in progress',
2014-05-27 18:44:30 +00:00
'9:EBADF:bad file descriptor' ,
'10:EBUSY:resource busy or locked' ,
2014-08-20 18:48:40 +00:00
//'11:ECONNABORTED:software caused connection abort',
//'12:ECONNREFUSED:connection refused',
//'13:ECONNRESET:connection reset by peer',
//'14:EDESTADDRREQ:destination address required',
//'15:EFAULT:bad address in system call argument',
//'16:EHOSTUNREACH:host is unreachable',
//'17:EINTR:interrupted system call',
2014-05-27 18:44:30 +00:00
'18:EINVAL:invalid argument' ,
2014-08-20 18:48:40 +00:00
//'19:EISCONN:socket is already connected',
//'20:EMFILE:too many open files',
//'21:EMSGSIZE:message too long',
//'22:ENETDOWN:network is down',
//'23:ENETUNREACH:network is unreachable',
//'24:ENFILE:file table overflow',
//'25:ENOBUFS:no buffer space available',
//'26:ENOMEM:not enough memory',
2014-05-27 18:44:30 +00:00
'27:ENOTDIR:not a directory' ,
'28:EISDIR:illegal operation on a directory' ,
2014-08-20 18:48:40 +00:00
//'29:ENONET:machine is not on the network',
2014-05-27 18:44:30 +00:00
// errno 30 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
2014-08-20 18:48:40 +00:00
//'31:ENOTCONN:socket is not connected',
//'32:ENOTSOCK:socket operation on non-socket',
//'33:ENOTSUP:operation not supported on socket',
2014-05-27 18:44:30 +00:00
'34:ENOENT:no such file or directory' ,
2014-08-20 18:48:40 +00:00
//'35:ENOSYS:function not implemented',
//'36:EPIPE:broken pipe',
//'37:EPROTO:protocol error',
//'38:EPROTONOSUPPORT:protocol not supported',
//'39:EPROTOTYPE:protocol wrong type for socket',
//'40:ETIMEDOUT:connection timed out',
//'41:ECHARSET:invalid Unicode character',
//'42:EAIFAMNOSUPPORT:address family for hostname not supported',
2014-05-27 18:44:30 +00:00
// errno 43 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
2014-08-20 18:48:40 +00:00
//'44:EAISERVICE:servname not supported for ai_socktype',
//'45:EAISOCKTYPE:ai_socktype not supported',
//'46:ESHUTDOWN:cannot send after transport endpoint shutdown',
2014-05-27 18:44:30 +00:00
'47:EEXIST:file already exists' ,
2014-08-20 18:48:40 +00:00
//'48:ESRCH:no such process',
//'49:ENAMETOOLONG:name too long',
2014-09-30 20:16:15 +00:00
'50:EPERM:operation not permitted' ,
2014-05-27 18:44:30 +00:00
'51:ELOOP:too many symbolic links encountered' ,
2014-08-20 18:48:40 +00:00
//'52:EXDEV:cross-device link not permitted',
2014-05-27 18:44:30 +00:00
'53:ENOTEMPTY:directory not empty' ,
2014-08-20 18:48:40 +00:00
//'54:ENOSPC:no space left on device',
2014-05-27 18:44:30 +00:00
'55:EIO:i/o error' ,
2014-08-20 18:48:40 +00:00
//'56:EROFS:read-only file system',
//'57:ENODEV:no such device',
//'58:ESPIPE:invalid seek',
//'59:ECANCELED:operation canceled',
2018-06-28 17:35:20 +00:00
=== === =
return ( ( this [ offset ] ) |
( this [ offset + 1 ] << 8 ) |
( this [ offset + 2 ] << 16 ) ) +
( this [ offset + 3 ] * 0x1000000 )
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Buffer . prototype . readUInt32BE = function readUInt32BE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
2014-08-20 18:48:40 +00:00
2018-06-28 17:35:20 +00:00
return ( this [ offset ] * 0x1000000 ) +
( ( this [ offset + 1 ] << 16 ) |
( this [ offset + 2 ] << 8 ) |
this [ offset + 3 ] )
}
2014-08-20 18:48:40 +00:00
2018-06-28 17:35:20 +00:00
Buffer . prototype . readIntLE = function readIntLE ( offset , byteLength , noAssert ) {
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) checkOffset ( offset , byteLength , this . length )
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var val = this [ offset ]
var mul = 1
var i = 0
while ( ++ i < byteLength && ( mul *= 0x100 ) ) {
val += this [ offset + i ] * mul
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
mul *= 0x80
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( val >= mul ) val -= Math . pow ( 2 , 8 * byteLength )
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
return val
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
var Path = require ( '../path.js' ) ;
2014-05-27 18:44:30 +00:00
var normalize = Path . normalize ;
var dirname = Path . dirname ;
var basename = Path . basename ;
var isAbsolutePath = Path . isAbsolute ;
var isNullPath = Path . isNull ;
2015-06-29 16:29:46 +00:00
var Constants = require ( '../constants.js' ) ;
2018-05-29 18:03:59 +00:00
var NODE _TYPE _FILE = Constants . NODE _TYPE _FILE ;
var NODE _TYPE _DIRECTORY = Constants . NODE _TYPE _DIRECTORY ;
var NODE _TYPE _SYMBOLIC _LINK = Constants . NODE _TYPE _SYMBOLIC _LINK ;
var NODE _TYPE _META = Constants . NODE _TYPE _META ;
var DEFAULT _FILE _PERMISSIONS = Constants . DEFAULT _FILE _PERMISSIONS ;
var DEFAULT _DIR _PERMISSIONS = Constants . DEFAULT _DIR _PERMISSIONS ;
var FULL _READ _WRITE _EXEC _PERMISSIONS = Constants . FULL _READ _WRITE _EXEC _PERMISSIONS ;
2018-06-28 17:35:20 +00:00
=== === =
Buffer . prototype . readIntBE = function readIntBE ( offset , byteLength , noAssert ) {
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) checkOffset ( offset , byteLength , this . length )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var i = byteLength
var mul = 1
var val = this [ offset + -- i ]
while ( i > 0 && ( mul *= 0x100 ) ) {
val += this [ offset + -- i ] * mul
}
mul *= 0x80
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( val >= mul ) val -= Math . pow ( 2 , 8 * byteLength )
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
return val
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Buffer . prototype . readInt8 = function readInt8 ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 1 , this . length )
if ( ! ( this [ offset ] & 0x80 ) ) return ( this [ offset ] )
return ( ( 0xff - this [ offset ] + 1 ) * - 1 )
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Buffer . prototype . readInt16LE = function readInt16LE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 2 , this . length )
var val = this [ offset ] | ( this [ offset + 1 ] << 8 )
return ( val & 0x8000 ) ? val | 0xFFFF0000 : val
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
} ) . call ( this , require ( "buffer" ) . Buffer )
} , { "buffer" : 6 } ] , 15 : [ function ( require , module , exports ) {
var O _READ = 'READ' ;
var O _WRITE = 'WRITE' ;
var O _CREATE = 'CREATE' ;
var O _EXCLUSIVE = 'EXCLUSIVE' ;
var O _TRUNCATE = 'TRUNCATE' ;
var O _APPEND = 'APPEND' ;
var XATTR _CREATE = 'CREATE' ;
var XATTR _REPLACE = 'REPLACE' ;
=== === =
Buffer . prototype . readInt16BE = function readInt16BE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 2 , this . length )
var val = this [ offset + 1 ] | ( this [ offset ] << 8 )
return ( val & 0x8000 ) ? val | 0xFFFF0000 : val
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function complete ( error ) {
context . changes . push ( { event : 'change' , path : path } ) ;
callback ( error ) ;
}
2018-06-28 17:35:20 +00:00
=== === =
Buffer . prototype . readInt32LE = function readInt32LE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
return ( this [ offset ] ) |
( this [ offset + 1 ] << 8 ) |
( this [ offset + 2 ] << 16 ) |
( this [ offset + 3 ] << 24 )
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
/ * *
* make _node ( )
* /
// in: file or directory path
// out: new node representing file/directory
2018-05-29 18:03:59 +00:00
function make _node ( context , path , type , callback ) {
if ( type !== NODE _TYPE _DIRECTORY && type !== NODE _TYPE _FILE ) {
return callback ( new Errors . EINVAL ( 'type must be a directory or file' , path ) ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
Buffer . prototype . readInt32BE = function readInt32BE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
return ( this [ offset ] << 24 ) |
( this [ offset + 1 ] << 16 ) |
( this [ offset + 2 ] << 8 ) |
( this [ offset + 3 ] )
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Buffer . prototype . readFloatLE = function readFloatLE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
return ieee754 . read ( this , offset , true , 23 , 4 )
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
// Check if the parent node exists
function create _node _in _parent ( error , parentDirectoryNode ) {
if ( error ) {
callback ( error ) ;
2018-05-29 18:03:59 +00:00
} else if ( parentDirectoryNode . type !== NODE _TYPE _DIRECTORY ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . ENOTDIR ( 'a component of the path prefix is not a directory' , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
parentNode = parentDirectoryNode ;
find _node ( context , path , check _if _node _exists ) ;
}
}
2018-06-28 17:35:20 +00:00
=== === =
Buffer . prototype . readFloatBE = function readFloatBE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 4 , this . length )
return ieee754 . read ( this , offset , false , 23 , 4 )
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Buffer . prototype . readDoubleLE = function readDoubleLE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 8 , this . length )
return ieee754 . read ( this , offset , true , 52 , 8 )
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
// Create the new node
function create _node ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
parentNodeData = result ;
2018-05-29 18:03:59 +00:00
Node . create ( {
guid : context . guid ,
type : type
} , function ( error , result ) {
2014-07-14 20:01:52 +00:00
if ( error ) {
callback ( error ) ;
return ;
}
node = result ;
node . nlinks += 1 ;
2014-08-17 05:56:03 +00:00
context . putObject ( node . id , node , update _parent _node _data ) ;
2014-07-14 20:01:52 +00:00
} ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
=== === =
Buffer . prototype . readDoubleBE = function readDoubleBE ( offset , noAssert ) {
if ( ! noAssert ) checkOffset ( offset , 8 , this . length )
return ieee754 . read ( this , offset , false , 52 , 8 )
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function checkInt ( buf , value , offset , ext , max , min ) {
if ( ! Buffer . isBuffer ( buf ) ) throw new TypeError ( '"buffer" argument must be a Buffer instance' )
if ( value > max || value < min ) throw new RangeError ( '"value" argument is out of bounds' )
if ( offset + ext > buf . length ) throw new RangeError ( 'Index out of range' )
}
Buffer . prototype . writeUIntLE = function writeUIntLE ( value , offset , byteLength , noAssert ) {
value = + value
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) {
var maxBytes = Math . pow ( 2 , 8 * byteLength ) - 1
checkInt ( this , value , offset , byteLength , maxBytes , 0 )
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
// Update the parent nodes data
function update _parent _node _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
2018-05-29 18:03:59 +00:00
parentNodeData [ name ] = new DirectoryEntry ( node . id , type ) ;
2014-08-17 05:56:03 +00:00
context . putObject ( parentNode . data , parentNodeData , update _time ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
var mul = 1
var i = 0
this [ offset ] = value & 0xFF
while ( ++ i < byteLength && ( mul *= 0x100 ) ) {
this [ offset + i ] = ( value / mul ) & 0xFF
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
return offset + byteLength
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
Buffer . prototype . writeUIntBE = function writeUIntBE ( value , offset , byteLength , noAssert ) {
value = + value
offset = offset | 0
byteLength = byteLength | 0
if ( ! noAssert ) {
var maxBytes = Math . pow ( 2 , 8 * byteLength ) - 1
checkInt ( this , value , offset , byteLength , maxBytes , 0 )
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function read _root _directory _node ( error , superNode ) {
if ( error ) {
callback ( error ) ;
2018-05-29 18:03:59 +00:00
} else if ( ! superNode || superNode . type !== NODE _TYPE _META || ! superNode . rnode ) {
2014-05-27 18:44:30 +00:00
callback ( new Errors . EFILESYSTEMERROR ( ) ) ;
} else {
2014-08-17 05:56:03 +00:00
context . getObject ( superNode . rnode , check _root _directory _node ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
var i = byteLength - 1
var mul = 1
this [ offset + i ] = value & 0xFF
while ( -- i >= 0 && ( mul *= 0x100 ) ) {
this [ offset + i ] = ( value / mul ) & 0xFF
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
return offset + byteLength
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Buffer . prototype . writeUInt8 = function writeUInt8 ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 1 , 0xff , 0 )
if ( ! Buffer . TYPED _ARRAY _SUPPORT ) value = Math . floor ( value )
this [ offset ] = ( value & 0xff )
return offset + 1
}
function objectWriteUInt16 ( buf , value , offset , littleEndian ) {
if ( value < 0 ) value = 0xffff + value + 1
for ( var i = 0 , j = Math . min ( buf . length - offset , 2 ) ; i < j ; ++ i ) {
buf [ offset + i ] = ( value & ( 0xff << ( 8 * ( littleEndian ? i : 1 - i ) ) ) ) >>>
( littleEndian ? i : 1 - i ) * 8
}
}
<< << << < HEAD
} , { } ] , 16 : [ function ( require , module , exports ) {
var MODE _FILE = require ( './constants.js' ) . MODE _FILE ;
=== === =
Buffer . prototype . writeUInt16LE = function writeUInt16LE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 2 , 0xffff , 0 )
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value & 0xff )
this [ offset + 1 ] = ( value >>> 8 )
} else {
objectWriteUInt16 ( this , value , offset , true )
}
return offset + 2
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
Buffer . prototype . writeUInt16BE = function writeUInt16BE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 2 , 0xffff , 0 )
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value >>> 8 )
this [ offset + 1 ] = ( value & 0xff )
} else {
objectWriteUInt16 ( this , value , offset , false )
}
return offset + 2
}
<< << << < HEAD
} , { "./constants.js" : 15 } ] , 17 : [ function ( require , module , exports ) {
( function ( Buffer ) {
// Adapt encodings to work with Buffer or Uint8Array, they expect the latter
function decode ( buf ) {
return buf . toString ( 'utf8' ) ;
=== === =
function objectWriteUInt32 ( buf , value , offset , littleEndian ) {
if ( value < 0 ) value = 0xffffffff + value + 1
for ( var i = 0 , j = Math . min ( buf . length - offset , 4 ) ; i < j ; ++ i ) {
buf [ offset + i ] = ( value >>> ( littleEndian ? i : 3 - i ) * 8 ) & 0xff
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
Buffer . prototype . writeUInt32LE = function writeUInt32LE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 4 , 0xffffffff , 0 )
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset + 3 ] = ( value >>> 24 )
this [ offset + 2 ] = ( value >>> 16 )
this [ offset + 1 ] = ( value >>> 8 )
this [ offset ] = ( value & 0xff )
} else {
objectWriteUInt32 ( this , value , offset , true )
}
return offset + 4
}
Buffer . prototype . writeUInt32BE = function writeUInt32BE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 4 , 0xffffffff , 0 )
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value >>> 24 )
this [ offset + 1 ] = ( value >>> 16 )
this [ offset + 2 ] = ( value >>> 8 )
this [ offset + 3 ] = ( value & 0xff )
} else {
objectWriteUInt32 ( this , value , offset , false )
}
return offset + 4
}
<< << << < HEAD
} ) . call ( this , require ( "buffer" ) . Buffer )
} , { "buffer" : 6 } ] , 18 : [ function ( require , module , exports ) {
var errors = { } ;
[
/ * *
* node . js errors - we only use some of these , add as needed .
* /
//'-1:UNKNOWN:unknown error',
//'0:OK:success',
//'1:EOF:end of file',
//'2:EADDRINFO:getaddrinfo error',
//'3:EACCES:permission denied',
//'4:EAGAIN:resource temporarily unavailable',
//'5:EADDRINUSE:address already in use',
//'6:EADDRNOTAVAIL:address not available',
//'7:EAFNOSUPPORT:address family not supported',
//'8:EALREADY:connection already in progress',
'9:EBADF:bad file descriptor' ,
'10:EBUSY:resource busy or locked' ,
//'11:ECONNABORTED:software caused connection abort',
//'12:ECONNREFUSED:connection refused',
//'13:ECONNRESET:connection reset by peer',
//'14:EDESTADDRREQ:destination address required',
//'15:EFAULT:bad address in system call argument',
//'16:EHOSTUNREACH:host is unreachable',
//'17:EINTR:interrupted system call',
'18:EINVAL:invalid argument' ,
//'19:EISCONN:socket is already connected',
//'20:EMFILE:too many open files',
//'21:EMSGSIZE:message too long',
//'22:ENETDOWN:network is down',
//'23:ENETUNREACH:network is unreachable',
//'24:ENFILE:file table overflow',
//'25:ENOBUFS:no buffer space available',
//'26:ENOMEM:not enough memory',
'27:ENOTDIR:not a directory' ,
'28:EISDIR:illegal operation on a directory' ,
//'29:ENONET:machine is not on the network',
// errno 30 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
//'31:ENOTCONN:socket is not connected',
//'32:ENOTSOCK:socket operation on non-socket',
//'33:ENOTSUP:operation not supported on socket',
'34:ENOENT:no such file or directory' ,
//'35:ENOSYS:function not implemented',
//'36:EPIPE:broken pipe',
//'37:EPROTO:protocol error',
//'38:EPROTONOSUPPORT:protocol not supported',
//'39:EPROTOTYPE:protocol wrong type for socket',
//'40:ETIMEDOUT:connection timed out',
//'41:ECHARSET:invalid Unicode character',
//'42:EAIFAMNOSUPPORT:address family for hostname not supported',
// errno 43 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
//'44:EAISERVICE:servname not supported for ai_socktype',
//'45:EAISOCKTYPE:ai_socktype not supported',
//'46:ESHUTDOWN:cannot send after transport endpoint shutdown',
'47:EEXIST:file already exists' ,
//'48:ESRCH:no such process',
//'49:ENAMETOOLONG:name too long',
'50:EPERM:operation not permitted' ,
'51:ELOOP:too many symbolic links encountered' ,
//'52:EXDEV:cross-device link not permitted',
'53:ENOTEMPTY:directory not empty' ,
//'54:ENOSPC:no space left on device',
'55:EIO:i/o error' ,
//'56:EROFS:read-only file system',
//'57:ENODEV:no such device',
//'58:ESPIPE:invalid seek',
//'59:ECANCELED:operation canceled',
=== === =
Buffer . prototype . writeIntLE = function writeIntLE ( value , offset , byteLength , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) {
var limit = Math . pow ( 2 , 8 * byteLength - 1 )
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
checkInt ( this , value , offset , byteLength , limit - 1 , - limit )
}
var i = 0
var mul = 1
var sub = 0
this [ offset ] = value & 0xFF
while ( ++ i < byteLength && ( mul *= 0x100 ) ) {
if ( value < 0 && sub === 0 && this [ offset + i - 1 ] !== 0 ) {
sub = 1
}
this [ offset + i ] = ( ( value / mul ) >> 0 ) - sub & 0xFF
}
return offset + byteLength
}
Buffer . prototype . writeIntBE = function writeIntBE ( value , offset , byteLength , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) {
var limit = Math . pow ( 2 , 8 * byteLength - 1 )
checkInt ( this , value , offset , byteLength , limit - 1 , - limit )
}
var i = byteLength - 1
var mul = 1
var sub = 0
this [ offset + i ] = value & 0xFF
while ( -- i >= 0 && ( mul *= 0x100 ) ) {
if ( value < 0 && sub === 0 && this [ offset + i + 1 ] !== 0 ) {
sub = 1
}
this [ offset + i ] = ( ( value / mul ) >> 0 ) - sub & 0xFF
}
return offset + byteLength
}
Buffer . prototype . writeInt8 = function writeInt8 ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 1 , 0x7f , - 0x80 )
if ( ! Buffer . TYPED _ARRAY _SUPPORT ) value = Math . floor ( value )
if ( value < 0 ) value = 0xff + value + 1
this [ offset ] = ( value & 0xff )
return offset + 1
}
<< << << < HEAD
} , { } ] , 19 : [ function ( require , module , exports ) {
var _ = require ( '../../lib/nodash.js' ) ;
var Path = require ( '../path.js' ) ;
var normalize = Path . normalize ;
var dirname = Path . dirname ;
var basename = Path . basename ;
var isAbsolutePath = Path . isAbsolute ;
var isNullPath = Path . isNull ;
var Constants = require ( '../constants.js' ) ;
var MODE _FILE = Constants . MODE _FILE ;
var MODE _DIRECTORY = Constants . MODE _DIRECTORY ;
var MODE _SYMBOLIC _LINK = Constants . MODE _SYMBOLIC _LINK ;
var MODE _META = Constants . MODE _META ;
=== === =
Buffer . prototype . writeInt16LE = function writeInt16LE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 2 , 0x7fff , - 0x8000 )
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value & 0xff )
this [ offset + 1 ] = ( value >>> 8 )
} else {
objectWriteUInt16 ( this , value , offset , true )
}
return offset + 2
}
Buffer . prototype . writeInt16BE = function writeInt16BE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 2 , 0x7fff , - 0x8000 )
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value >>> 8 )
this [ offset + 1 ] = ( value & 0xff )
} else {
objectWriteUInt16 ( this , value , offset , false )
}
return offset + 2
}
Buffer . prototype . writeInt32LE = function writeInt32LE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 4 , 0x7fffffff , - 0x80000000 )
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value & 0xff )
this [ offset + 1 ] = ( value >>> 8 )
this [ offset + 2 ] = ( value >>> 16 )
this [ offset + 3 ] = ( value >>> 24 )
} else {
objectWriteUInt32 ( this , value , offset , true )
}
return offset + 4
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
Buffer . prototype . writeInt32BE = function writeInt32BE ( value , offset , noAssert ) {
value = + value
offset = offset | 0
if ( ! noAssert ) checkInt ( this , value , offset , 4 , 0x7fffffff , - 0x80000000 )
if ( value < 0 ) value = 0xffffffff + value + 1
if ( Buffer . TYPED _ARRAY _SUPPORT ) {
this [ offset ] = ( value >>> 24 )
this [ offset + 1 ] = ( value >>> 16 )
this [ offset + 2 ] = ( value >>> 8 )
this [ offset + 3 ] = ( value & 0xff )
} else {
objectWriteUInt32 ( this , value , offset , false )
}
return offset + 4
}
function checkIEEE754 ( buf , value , offset , ext , max , min ) {
if ( offset + ext > buf . length ) throw new RangeError ( 'Index out of range' )
if ( offset < 0 ) throw new RangeError ( 'Index out of range' )
}
<< << << < HEAD
var XATTR _CREATE = Constants . XATTR _CREATE ;
var XATTR _REPLACE = Constants . XATTR _REPLACE ;
var FS _NOMTIME = Constants . FS _NOMTIME ;
var FS _NOCTIME = Constants . FS _NOCTIME ;
var Encoding = require ( '../encoding.js' ) ;
var Errors = require ( '../errors.js' ) ;
var DirectoryEntry = require ( '../directory-entry.js' ) ;
var OpenFileDescription = require ( '../open-file-description.js' ) ;
var SuperNode = require ( '../super-node.js' ) ;
var Node = require ( '../node.js' ) ;
var Stats = require ( '../stats.js' ) ;
var Buffer = require ( '../buffer.js' ) ;
=== === =
function writeFloat ( buf , value , offset , littleEndian , noAssert ) {
if ( ! noAssert ) {
checkIEEE754 ( buf , value , offset , 4 , 3.4028234663852886 e + 38 , - 3.4028234663852886 e + 38 )
}
ieee754 . write ( buf , value , offset , littleEndian , 23 , 4 )
return offset + 4
}
Buffer . prototype . writeFloatLE = function writeFloatLE ( value , offset , noAssert ) {
return writeFloat ( this , value , offset , true , noAssert )
}
Buffer . prototype . writeFloatBE = function writeFloatBE ( value , offset , noAssert ) {
return writeFloat ( this , value , offset , false , noAssert )
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
function writeDouble ( buf , value , offset , littleEndian , noAssert ) {
if ( ! noAssert ) {
checkIEEE754 ( buf , value , offset , 8 , 1.7976931348623157 E + 308 , - 1.7976931348623157 E + 308 )
}
ieee754 . write ( buf , value , offset , littleEndian , 52 , 8 )
return offset + 8
}
Buffer . prototype . writeDoubleLE = function writeDoubleLE ( value , offset , noAssert ) {
return writeDouble ( this , value , offset , true , noAssert )
}
Buffer . prototype . writeDoubleBE = function writeDoubleBE ( value , offset , noAssert ) {
return writeDouble ( this , value , offset , false , noAssert )
}
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
Buffer . prototype . copy = function copy ( target , targetStart , start , end ) {
if ( ! start ) start = 0
if ( ! end && end !== 0 ) end = this . length
if ( targetStart >= target . length ) targetStart = target . length
if ( ! targetStart ) targetStart = 0
if ( end > 0 && end < start ) end = start
// Copy 0 bytes; we're done
if ( end === start ) return 0
if ( target . length === 0 || this . length === 0 ) return 0
// Fatal error conditions
if ( targetStart < 0 ) {
throw new RangeError ( 'targetStart out of bounds' )
}
if ( start < 0 || start >= this . length ) throw new RangeError ( 'sourceStart out of bounds' )
if ( end < 0 ) throw new RangeError ( 'sourceEnd out of bounds' )
// Are we oob?
if ( end > this . length ) end = this . length
if ( target . length - targetStart < end - start ) {
end = target . length - targetStart + start
}
var len = end - start
var i
if ( this === target && start < targetStart && targetStart < end ) {
// descending copy from end
for ( i = len - 1 ; i >= 0 ; -- i ) {
target [ i + targetStart ] = this [ i + start ]
}
} else if ( len < 1000 || ! Buffer . TYPED _ARRAY _SUPPORT ) {
// ascending copy from start
for ( i = 0 ; i < len ; ++ i ) {
target [ i + targetStart ] = this [ i + start ]
}
} else {
Uint8Array . prototype . set . call (
target ,
this . subarray ( start , start + len ) ,
targetStart
)
}
return len
}
// Usage:
// buffer.fill(number[, offset[, end]])
// buffer.fill(buffer[, offset[, end]])
// buffer.fill(string[, offset[, end]][, encoding])
Buffer . prototype . fill = function fill ( val , start , end , encoding ) {
// Handle string cases:
if ( typeof val === 'string' ) {
if ( typeof start === 'string' ) {
encoding = start
start = 0
end = this . length
} else if ( typeof end === 'string' ) {
encoding = end
end = this . length
}
if ( val . length === 1 ) {
var code = val . charCodeAt ( 0 )
if ( code < 256 ) {
val = code
}
}
if ( encoding !== undefined && typeof encoding !== 'string' ) {
throw new TypeError ( 'encoding must be a string' )
}
if ( typeof encoding === 'string' && ! Buffer . isEncoding ( encoding ) ) {
throw new TypeError ( 'Unknown encoding: ' + encoding )
}
} else if ( typeof val === 'number' ) {
val = val & 255
}
// Invalid ranges are not set to a default, so can range check early.
if ( start < 0 || this . length < start || this . length < end ) {
throw new RangeError ( 'Out of range index' )
}
if ( end <= start ) {
return this
}
start = start >>> 0
end = end === undefined ? this . length : end >>> 0
if ( ! val ) val = 0
var i
if ( typeof val === 'number' ) {
for ( i = start ; i < end ; ++ i ) {
this [ i ] = val
}
} else {
var bytes = Buffer . isBuffer ( val )
? val
: utf8ToBytes ( new Buffer ( val , encoding ) . toString ( ) )
var len = bytes . length
for ( i = 0 ; i < end - start ; ++ i ) {
this [ i + start ] = bytes [ i % len ]
}
}
return this
}
// HELPER FUNCTIONS
// ================
var INVALID _BASE64 _RE = /[^+\/0-9A-Za-z-_]/g
function base64clean ( str ) {
// Node strips out invalid characters like \n and \t from the string, base64-js does not
str = stringtrim ( str ) . replace ( INVALID _BASE64 _RE , '' )
// Node converts strings with length < 2 to ''
if ( str . length < 2 ) return ''
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
while ( str . length % 4 !== 0 ) {
str = str + '='
}
return str
}
function stringtrim ( str ) {
if ( str . trim ) return str . trim ( )
return str . replace ( /^\s+|\s+$/g , '' )
}
function toHex ( n ) {
if ( n < 16 ) return '0' + n . toString ( 16 )
return n . toString ( 16 )
}
function utf8ToBytes ( string , units ) {
units = units || Infinity
var codePoint
var length = string . length
var leadSurrogate = null
var bytes = [ ]
for ( var i = 0 ; i < length ; ++ i ) {
codePoint = string . charCodeAt ( i )
// is surrogate component
if ( codePoint > 0xD7FF && codePoint < 0xE000 ) {
// last char was a lead
if ( ! leadSurrogate ) {
// no lead yet
if ( codePoint > 0xDBFF ) {
// unexpected trail
if ( ( units -= 3 ) > - 1 ) bytes . push ( 0xEF , 0xBF , 0xBD )
continue
} else if ( i + 1 === length ) {
// unpaired lead
if ( ( units -= 3 ) > - 1 ) bytes . push ( 0xEF , 0xBF , 0xBD )
continue
}
// valid lead
leadSurrogate = codePoint
continue
}
// 2 leads in a row
if ( codePoint < 0xDC00 ) {
if ( ( units -= 3 ) > - 1 ) bytes . push ( 0xEF , 0xBF , 0xBD )
leadSurrogate = codePoint
continue
}
// valid surrogate pair
codePoint = ( leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 ) + 0x10000
} else if ( leadSurrogate ) {
// valid bmp char, but last char was a lead
if ( ( units -= 3 ) > - 1 ) bytes . push ( 0xEF , 0xBF , 0xBD )
}
leadSurrogate = null
// encode utf8
if ( codePoint < 0x80 ) {
if ( ( units -= 1 ) < 0 ) break
bytes . push ( codePoint )
} else if ( codePoint < 0x800 ) {
if ( ( units -= 2 ) < 0 ) break
bytes . push (
codePoint >> 0x6 | 0xC0 ,
codePoint & 0x3F | 0x80
)
} else if ( codePoint < 0x10000 ) {
if ( ( units -= 3 ) < 0 ) break
bytes . push (
codePoint >> 0xC | 0xE0 ,
codePoint >> 0x6 & 0x3F | 0x80 ,
codePoint & 0x3F | 0x80
)
} else if ( codePoint < 0x110000 ) {
if ( ( units -= 4 ) < 0 ) break
bytes . push (
codePoint >> 0x12 | 0xF0 ,
codePoint >> 0xC & 0x3F | 0x80 ,
codePoint >> 0x6 & 0x3F | 0x80 ,
codePoint & 0x3F | 0x80
)
} else {
throw new Error ( 'Invalid code point' )
}
}
return bytes
}
function asciiToBytes ( str ) {
var byteArray = [ ]
for ( var i = 0 ; i < str . length ; ++ i ) {
// Node's code seems to be doing this and not & 0x7F..
byteArray . push ( str . charCodeAt ( i ) & 0xFF )
}
return byteArray
}
function utf16leToBytes ( str , units ) {
var c , hi , lo
var byteArray = [ ]
for ( var i = 0 ; i < str . length ; ++ i ) {
if ( ( units -= 2 ) < 0 ) break
c = str . charCodeAt ( i )
hi = c >> 8
lo = c % 256
byteArray . push ( lo )
byteArray . push ( hi )
}
return byteArray
}
function base64ToBytes ( str ) {
return base64 . toByteArray ( base64clean ( str ) )
}
function blitBuffer ( src , dst , offset , length ) {
for ( var i = 0 ; i < length ; ++ i ) {
if ( ( i + offset >= dst . length ) || ( i >= src . length ) ) break
dst [ i + offset ] = src [ i ]
}
return i
}
function isnan ( val ) {
return val !== val // eslint-disable-line no-self-compare
}
} , { "base64-js" : 29 , "ieee754" : 30 , "isarray" : 31 , "buffer" : 11 } ] , 3 : [ function ( require , module , exports ) {
var Buffer = require ( "buffer" ) . Buffer ;
function FilerBuffer ( subject , encoding , nonZero ) {
// Automatically turn ArrayBuffer into Uint8Array so that underlying
// Buffer code doesn't just throw away and ignore ArrayBuffer data.
if ( subject instanceof ArrayBuffer ) {
subject = new Uint8Array ( subject ) ;
}
return new Buffer ( subject , encoding , nonZero ) ;
} ;
// Inherit prototype from Buffer
FilerBuffer . prototype = Object . create ( Buffer . prototype ) ;
FilerBuffer . prototype . constructor = FilerBuffer ;
// Also copy static methods onto FilerBuffer ctor
Object . keys ( Buffer ) . forEach ( function ( p ) {
if ( Buffer . hasOwnProperty ( p ) ) {
FilerBuffer [ p ] = Buffer [ p ] ;
}
<< << << < HEAD
}
/ * *
* set extended attribute ( refactor )
* /
function set _extended _attribute ( context , path , node , name , value , flag , callback ) {
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
} else {
update _node _times ( context , path , node , { ctime : Date . now ( ) } , callback ) ;
}
}
var xattrs = node . xattrs ;
if ( flag === XATTR _CREATE && xattrs . hasOwnProperty ( name ) ) {
callback ( new Errors . EEXIST ( 'attribute already exists' , path ) ) ;
}
else if ( flag === XATTR _REPLACE && ! xattrs . hasOwnProperty ( name ) ) {
callback ( new Errors . ENOATTR ( null , path ) ) ;
}
else {
xattrs [ name ] = value ;
context . putObject ( node . id , node , update _time ) ;
}
=== === =
} ) ;
module . exports = FilerBuffer ;
} , { "buffer" : 11 } ] , 50 : [ function ( require , module , exports ) {
var global = arguments [ 3 ] ;
var FILE _SYSTEM _NAME = require ( '../constants.js' ) . FILE _SYSTEM _NAME ;
var FILE _STORE _NAME = require ( '../constants.js' ) . FILE _STORE _NAME ;
var IDB _RW = require ( '../constants.js' ) . IDB _RW ;
var IDB _RO = require ( '../constants.js' ) . IDB _RO ;
var Errors = require ( '../errors.js' ) ;
var FilerBuffer = require ( '../buffer.js' ) ;
var indexedDB = global . indexedDB || global . mozIndexedDB || global . webkitIndexedDB || global . msIndexedDB ;
function IndexedDBContext ( db , mode ) {
var transaction = db . transaction ( FILE _STORE _NAME , mode ) ;
this . objectStore = transaction . objectStore ( FILE _STORE _NAME ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
IndexedDBContext . prototype . clear = function ( callback ) {
try {
var request = this . objectStore . clear ( ) ;
request . onsuccess = function ( event ) {
callback ( ) ;
} ;
request . onerror = function ( error ) {
callback ( error ) ;
} ;
} catch ( e ) {
callback ( e ) ;
}
} ;
function _get ( objectStore , key , callback ) {
try {
var request = objectStore . get ( key ) ;
request . onsuccess = function onsuccess ( event ) {
var result = event . target . result ;
callback ( null , result ) ;
} ;
request . onerror = function onerror ( error ) {
callback ( error ) ;
} ;
} catch ( e ) {
callback ( e ) ;
}
}
IndexedDBContext . prototype . getObject = function ( key , callback ) {
_get ( this . objectStore , key , callback ) ;
} ;
IndexedDBContext . prototype . getBuffer = function ( key , callback ) {
_get ( this . objectStore , key , function ( err , arrayBuffer ) {
if ( err ) {
return callback ( err ) ;
}
callback ( null , new FilerBuffer ( arrayBuffer ) ) ;
} ) ;
} ;
function _put ( objectStore , key , value , callback ) {
try {
var request = objectStore . put ( value , key ) ;
request . onsuccess = function onsuccess ( event ) {
var result = event . target . result ;
callback ( null , result ) ;
} ;
request . onerror = function onerror ( error ) {
callback ( error ) ;
} ;
} catch ( e ) {
callback ( e ) ;
}
}
IndexedDBContext . prototype . putObject = function ( key , value , callback ) {
_put ( this . objectStore , key , value , callback ) ;
} ;
IndexedDBContext . prototype . putBuffer = function ( key , uint8BackedBuffer , callback ) {
_put ( this . objectStore , key , uint8BackedBuffer . buffer , callback ) ;
} ;
IndexedDBContext . prototype . delete = function ( key , callback ) {
try {
var request = this . objectStore . delete ( key ) ;
request . onsuccess = function onsuccess ( event ) {
var result = event . target . result ;
callback ( null , result ) ;
} ;
request . onerror = function ( error ) {
callback ( error ) ;
} ;
} catch ( e ) {
callback ( e ) ;
}
} ;
function IndexedDB ( name ) {
this . name = name || FILE _SYSTEM _NAME ;
this . db = null ;
}
IndexedDB . isSupported = function ( ) {
return ! ! indexedDB ;
} ;
IndexedDB . prototype . open = function ( callback ) {
var that = this ;
// Bail if we already have a db open
if ( that . db ) {
return callback ( ) ;
}
// NOTE: we're not using versioned databases.
var openRequest = indexedDB . open ( that . name ) ;
// If the db doesn't exist, we'll create it
openRequest . onupgradeneeded = function onupgradeneeded ( event ) {
var db = event . target . result ;
if ( db . objectStoreNames . contains ( FILE _STORE _NAME ) ) {
db . deleteObjectStore ( FILE _STORE _NAME ) ;
}
db . createObjectStore ( FILE _STORE _NAME ) ;
} ;
openRequest . onsuccess = function onsuccess ( event ) {
that . db = event . target . result ;
callback ( ) ;
} ;
openRequest . onerror = function onerror ( error ) {
callback ( new Errors . EINVAL ( 'IndexedDB cannot be accessed. If private browsing is enabled, disable it.' ) ) ;
} ;
} ;
IndexedDB . prototype . getReadOnlyContext = function ( ) {
// Due to timing issues in Chrome with readwrite vs. readonly indexeddb transactions
// always use readwrite so we can make sure pending commits finish before callbacks.
// See https://github.com/js-platform/filer/issues/128
return new IndexedDBContext ( this . db , IDB _RW ) ;
} ;
IndexedDB . prototype . getReadWriteContext = function ( ) {
return new IndexedDBContext ( this . db , IDB _RW ) ;
} ;
module . exports = IndexedDB ;
} , { "../constants.js" : 15 , "../errors.js" : 5 , "../buffer.js" : 3 } ] , 60 : [ function ( require , module , exports ) {
/ *
* base64 - arraybuffer
* https : //github.com/niklasvh/base64-arraybuffer
*
* Copyright ( c ) 2012 Niklas von Hertzen
* Licensed under the MIT license .
* /
( function ( ) {
"use strict" ;
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ;
// Use a lookup table to find the index.
var lookup = new Uint8Array ( 256 ) ;
for ( var i = 0 ; i < chars . length ; i ++ ) {
lookup [ chars . charCodeAt ( i ) ] = i ;
}
exports . encode = function ( arraybuffer ) {
var bytes = new Uint8Array ( arraybuffer ) ,
i ,
len = bytes . length ,
base64 = "" ;
for ( i = 0 ; i < len ; i += 3 ) {
base64 += chars [ bytes [ i ] >> 2 ] ;
base64 += chars [ ( bytes [ i ] & 3 ) << 4 | bytes [ i + 1 ] >> 4 ] ;
base64 += chars [ ( bytes [ i + 1 ] & 15 ) << 2 | bytes [ i + 2 ] >> 6 ] ;
base64 += chars [ bytes [ i + 2 ] & 63 ] ;
}
if ( len % 3 === 2 ) {
base64 = base64 . substring ( 0 , base64 . length - 1 ) + "=" ;
} else if ( len % 3 === 1 ) {
base64 = base64 . substring ( 0 , base64 . length - 2 ) + "==" ;
}
return base64 ;
} ;
exports . decode = function ( base64 ) {
var bufferLength = base64 . length * 0.75 ,
len = base64 . length ,
i ,
p = 0 ,
encoded1 ,
encoded2 ,
encoded3 ,
encoded4 ;
if ( base64 [ base64 . length - 1 ] === "=" ) {
bufferLength -- ;
if ( base64 [ base64 . length - 2 ] === "=" ) {
bufferLength -- ;
}
}
var arraybuffer = new ArrayBuffer ( bufferLength ) ,
bytes = new Uint8Array ( arraybuffer ) ;
for ( i = 0 ; i < len ; i += 4 ) {
encoded1 = lookup [ base64 . charCodeAt ( i ) ] ;
encoded2 = lookup [ base64 . charCodeAt ( i + 1 ) ] ;
encoded3 = lookup [ base64 . charCodeAt ( i + 2 ) ] ;
encoded4 = lookup [ base64 . charCodeAt ( i + 3 ) ] ;
bytes [ p ++ ] = encoded1 << 2 | encoded2 >> 4 ;
bytes [ p ++ ] = ( encoded2 & 15 ) << 4 | encoded3 >> 2 ;
bytes [ p ++ ] = ( encoded3 & 3 ) << 6 | encoded4 & 63 ;
}
return arraybuffer ;
} ;
} ) ( ) ;
} , { } ] , 51 : [ function ( require , module , exports ) {
var global = arguments [ 3 ] ;
var FILE _SYSTEM _NAME = require ( '../constants.js' ) . FILE _SYSTEM _NAME ;
var FILE _STORE _NAME = require ( '../constants.js' ) . FILE _STORE _NAME ;
var WSQL _VERSION = require ( '../constants.js' ) . WSQL _VERSION ;
var WSQL _SIZE = require ( '../constants.js' ) . WSQL _SIZE ;
var WSQL _DESC = require ( '../constants.js' ) . WSQL _DESC ;
var Errors = require ( '../errors.js' ) ;
var FilerBuffer = require ( '../buffer.js' ) ;
var base64ArrayBuffer = require ( 'base64-arraybuffer' ) ;
function WebSQLContext ( db , isReadOnly ) {
var that = this ;
this . getTransaction = function ( callback ) {
if ( that . transaction ) {
callback ( that . transaction ) ;
return ;
}
// Either do readTransaction() (read-only) or transaction() (read/write)
db [ isReadOnly ? 'readTransaction' : 'transaction' ] ( function ( transaction ) {
that . transaction = transaction ;
callback ( transaction ) ;
} ) ;
} ;
}
WebSQLContext . prototype . clear = function ( callback ) {
function onError ( transaction , error ) {
callback ( error ) ;
}
function onSuccess ( transaction , result ) {
callback ( null ) ;
}
this . getTransaction ( function ( transaction ) {
transaction . executeSql ( "DELETE FROM " + FILE _STORE _NAME + ";" , [ ] , onSuccess , onError ) ;
} ) ;
} ;
function _get ( getTransaction , key , callback ) {
function onSuccess ( transaction , result ) {
// If the key isn't found, return null
var value = result . rows . length === 0 ? null : result . rows . item ( 0 ) . data ;
callback ( null , value ) ;
}
function onError ( transaction , error ) {
callback ( error ) ;
}
getTransaction ( function ( transaction ) {
transaction . executeSql ( "SELECT data FROM " + FILE _STORE _NAME + " WHERE id = ? LIMIT 1;" , [ key ] , onSuccess , onError ) ;
} ) ;
}
WebSQLContext . prototype . getObject = function ( key , callback ) {
_get ( this . getTransaction , key , function ( err , result ) {
if ( err ) {
return callback ( err ) ;
}
try {
if ( result ) {
result = JSON . parse ( result ) ;
}
} catch ( e ) {
return callback ( e ) ;
}
callback ( null , result ) ;
} ) ;
} ;
WebSQLContext . prototype . getBuffer = function ( key , callback ) {
_get ( this . getTransaction , key , function ( err , result ) {
if ( err ) {
return callback ( err ) ;
}
// Deal with zero-length ArrayBuffers, which will be encoded as ''
if ( result || result === '' ) {
var arrayBuffer = base64ArrayBuffer . decode ( result ) ;
result = new FilerBuffer ( arrayBuffer ) ;
}
callback ( null , result ) ;
} ) ;
} ;
function _put ( getTransaction , key , value , callback ) {
function onSuccess ( transaction , result ) {
callback ( null ) ;
}
function onError ( transaction , error ) {
callback ( error ) ;
}
getTransaction ( function ( transaction ) {
transaction . executeSql ( "INSERT OR REPLACE INTO " + FILE _STORE _NAME + " (id, data) VALUES (?, ?);" , [ key , value ] , onSuccess , onError ) ;
} ) ;
}
WebSQLContext . prototype . putObject = function ( key , value , callback ) {
var json = JSON . stringify ( value ) ;
_put ( this . getTransaction , key , json , callback ) ;
} ;
WebSQLContext . prototype . putBuffer = function ( key , uint8BackedBuffer , callback ) {
var base64 = base64ArrayBuffer . encode ( uint8BackedBuffer . buffer ) ;
_put ( this . getTransaction , key , base64 , callback ) ;
} ;
WebSQLContext . prototype . delete = function ( key , callback ) {
function onSuccess ( transaction , result ) {
callback ( null ) ;
}
function onError ( transaction , error ) {
callback ( error ) ;
}
this . getTransaction ( function ( transaction ) {
transaction . executeSql ( "DELETE FROM " + FILE _STORE _NAME + " WHERE id = ?;" , [ key ] , onSuccess , onError ) ;
} ) ;
} ;
function WebSQL ( name ) {
this . name = name || FILE _SYSTEM _NAME ;
this . db = null ;
}
WebSQL . isSupported = function ( ) {
return ! ! global . openDatabase ;
} ;
WebSQL . prototype . open = function ( callback ) {
var that = this ;
// Bail if we already have a db open
if ( that . db ) {
return callback ( ) ;
}
var db = global . openDatabase ( that . name , WSQL _VERSION , WSQL _DESC , WSQL _SIZE ) ;
if ( ! db ) {
callback ( "[WebSQL] Unable to open database." ) ;
return ;
}
function onError ( transaction , error ) {
if ( error . code === 5 ) {
callback ( new Errors . EINVAL ( 'WebSQL cannot be accessed. If private browsing is enabled, disable it.' ) ) ;
}
callback ( error ) ;
}
function onSuccess ( transaction , result ) {
that . db = db ;
callback ( ) ;
}
// Create the table and index we'll need to store the fs data.
db . transaction ( function ( transaction ) {
function createIndex ( transaction ) {
transaction . executeSql ( "CREATE INDEX IF NOT EXISTS idx_" + FILE _STORE _NAME + "_id" + " on " + FILE _STORE _NAME + " (id);" , [ ] , onSuccess , onError ) ;
}
transaction . executeSql ( "CREATE TABLE IF NOT EXISTS " + FILE _STORE _NAME + " (id unique, data TEXT);" , [ ] , createIndex , onError ) ;
} ) ;
} ;
WebSQL . prototype . getReadOnlyContext = function ( ) {
return new WebSQLContext ( this . db , true ) ;
} ;
WebSQL . prototype . getReadWriteContext = function ( ) {
return new WebSQLContext ( this . db , false ) ;
} ;
module . exports = WebSQL ;
} , { "../constants.js" : 15 , "../errors.js" : 5 , "../buffer.js" : 3 , "base64-arraybuffer" : 60 } ] , 59 : [ function ( require , module , exports ) {
// shim for using process in browser
var process = module . exports = { } ;
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout ;
var cachedClearTimeout ;
function defaultSetTimout ( ) {
throw new Error ( 'setTimeout has not been defined' ) ;
}
function defaultClearTimeout ( ) {
throw new Error ( 'clearTimeout has not been defined' ) ;
}
( function ( ) {
try {
if ( typeof setTimeout === 'function' ) {
cachedSetTimeout = setTimeout ;
} else {
cachedSetTimeout = defaultSetTimout ;
}
} catch ( e ) {
cachedSetTimeout = defaultSetTimout ;
}
try {
if ( typeof clearTimeout === 'function' ) {
cachedClearTimeout = clearTimeout ;
} else {
cachedClearTimeout = defaultClearTimeout ;
}
} catch ( e ) {
cachedClearTimeout = defaultClearTimeout ;
}
} ) ( ) ;
function runTimeout ( fun ) {
if ( cachedSetTimeout === setTimeout ) {
//normal enviroments in sane situations
return setTimeout ( fun , 0 ) ;
}
// if setTimeout wasn't available but was latter defined
if ( ( cachedSetTimeout === defaultSetTimout || ! cachedSetTimeout ) && setTimeout ) {
cachedSetTimeout = setTimeout ;
return setTimeout ( fun , 0 ) ;
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout ( fun , 0 ) ;
} catch ( e ) {
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout . call ( null , fun , 0 ) ;
} catch ( e ) {
// 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
return cachedSetTimeout . call ( this , fun , 0 ) ;
}
}
}
function runClearTimeout ( marker ) {
if ( cachedClearTimeout === clearTimeout ) {
//normal enviroments in sane situations
return clearTimeout ( marker ) ;
}
// if clearTimeout wasn't available but was latter defined
if ( ( cachedClearTimeout === defaultClearTimeout || ! cachedClearTimeout ) && clearTimeout ) {
cachedClearTimeout = clearTimeout ;
return clearTimeout ( marker ) ;
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout ( marker ) ;
} catch ( e ) {
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout . call ( null , marker ) ;
} catch ( e ) {
// 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.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout . call ( this , marker ) ;
}
}
}
var queue = [ ] ;
var draining = false ;
var currentQueue ;
var queueIndex = - 1 ;
function cleanUpNextTick ( ) {
if ( ! draining || ! currentQueue ) {
return ;
}
draining = false ;
if ( currentQueue . length ) {
queue = currentQueue . concat ( queue ) ;
} else {
queueIndex = - 1 ;
}
if ( queue . length ) {
drainQueue ( ) ;
}
}
function drainQueue ( ) {
if ( draining ) {
return ;
}
var timeout = runTimeout ( cleanUpNextTick ) ;
draining = true ;
var len = queue . length ;
while ( len ) {
currentQueue = queue ;
queue = [ ] ;
while ( ++ queueIndex < len ) {
if ( currentQueue ) {
currentQueue [ queueIndex ] . run ( ) ;
}
}
queueIndex = - 1 ;
len = queue . length ;
}
currentQueue = null ;
draining = false ;
runClearTimeout ( timeout ) ;
}
process . nextTick = function ( fun ) {
var args = new Array ( arguments . length - 1 ) ;
if ( arguments . length > 1 ) {
for ( var i = 1 ; i < arguments . length ; i ++ ) {
args [ i - 1 ] = arguments [ i ] ;
}
}
queue . push ( new Item ( fun , args ) ) ;
if ( queue . length === 1 && ! draining ) {
runTimeout ( drainQueue ) ;
}
} ;
// v8 likes predictible objects
function Item ( fun , array ) {
this . fun = fun ;
this . array = array ;
}
Item . prototype . run = function ( ) {
this . fun . apply ( null , this . array ) ;
} ;
process . title = 'browser' ;
process . browser = true ;
process . env = { } ;
process . argv = [ ] ;
process . version = '' ; // empty string to avoid regexp issues
process . versions = { } ;
function noop ( ) { }
<< << << < HEAD
function read _file _data ( error , result ) {
if ( error ) {
callback ( error ) ;
} else if ( result . mode === 'DIRECTORY' ) {
callback ( new Errors . EISDIR ( 'the named file is a directory' , ofd . path ) ) ;
} else {
fileNode = result ;
context . getBuffer ( fileNode . data , handle _file _data ) ;
}
}
=== === =
process . on = noop ;
process . addListener = noop ;
process . once = noop ;
process . off = noop ;
process . removeListener = noop ;
process . removeAllListeners = noop ;
process . emit = noop ;
process . prependListener = noop ;
process . prependOnceListener = noop ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
process . listeners = function ( name ) {
return [ ] ;
} ;
<< << << < HEAD
function stat _file ( context , path , callback ) {
path = normalize ( path ) ;
var name = basename ( path ) ;
find _node ( context , path , callback ) ;
}
function fstat _file ( context , ofd , callback ) {
ofd . getNode ( context , callback ) ;
}
=== === =
process . binding = function ( name ) {
throw new Error ( 'process.binding is not supported' ) ;
} ;
process . cwd = function ( ) {
return '/' ;
} ;
process . chdir = function ( dir ) {
throw new Error ( 'process.chdir is not supported' ) ;
} ;
process . umask = function ( ) {
return 0 ;
} ;
} , { } ] , 49 : [ function ( require , module , exports ) {
var process = require ( "process" ) ;
var define ;
/*global setImmediate: false, setTimeout: false, console: false */
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
/ * *
* async . js shim , based on https : //raw.github.com/caolan/async/master/lib/async.js Feb 18, 2014
* Used under MIT - https : //github.com/caolan/async/blob/master/LICENSE
* /
( function ( ) {
<< << << < HEAD
if ( ROOT _DIRECTORY _NAME == name ) {
find _node ( context , path , callback ) ;
} else {
find _node ( context , parentPath , read _directory _data ) ;
}
=== === =
var async = { } ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
// async.js functions used in Filer
//// nextTick implementation with browser-compatible fallback ////
if ( typeof process === 'undefined' || ! process . nextTick ) {
if ( typeof setImmediate === 'function' ) {
async . nextTick = function ( fn ) {
// not a direct alias for IE10 compatibility
setImmediate ( fn ) ;
} ;
async . setImmediate = async . nextTick ;
} else {
async . nextTick = function ( fn ) {
setTimeout ( fn , 0 ) ;
} ;
async . setImmediate = async . nextTick ;
}
} else {
<< << << < HEAD
directoryData = result ;
if ( ! _ ( directoryData ) . has ( name ) ) {
callback ( new Errors . ENOENT ( 'a component of the path does not name an existing file' , path ) ) ;
} else {
context . getObject ( directoryData [ name ] . id , callback ) ;
}
=== === =
async . nextTick = process . nextTick ;
if ( typeof setImmediate !== 'undefined' ) {
async . setImmediate = function ( fn ) {
// not a direct alias for IE10 compatibility
setImmediate ( fn ) ;
} ;
} else {
async . setImmediate = async . nextTick ;
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
async . eachSeries = function ( arr , iterator , callback ) {
callback = callback || function ( ) { } ;
if ( ! arr . length ) {
return callback ( ) ;
}
var completed = 0 ;
var iterate = function iterate ( ) {
iterator ( arr [ completed ] , function ( err ) {
if ( err ) {
callback ( err ) ;
callback = function callback ( ) { } ;
} else {
completed += 1 ;
if ( completed >= arr . length ) {
callback ( ) ;
} else {
iterate ( ) ;
}
}
} ) ;
} ;
iterate ( ) ;
} ;
async . forEachSeries = async . eachSeries ;
// AMD / RequireJS
if ( typeof define !== 'undefined' && define . amd ) {
define ( [ ] , function ( ) {
return async ;
} ) ;
}
// Node.js
else if ( typeof module !== 'undefined' && module . exports ) {
module . exports = async ;
}
// included directly via <script> tag
else {
root . async = async ;
}
} ) ( ) ;
} , { "process" : 59 } ] , 52 : [ function ( require , module , exports ) {
var FILE _SYSTEM _NAME = require ( '../constants.js' ) . FILE _SYSTEM _NAME ;
// NOTE: prefer setImmediate to nextTick for proper recursion yielding.
// see https://github.com/js-platform/filer/pull/24
var asyncCallback = require ( '../../lib/async.js' ) . setImmediate ;
/ * *
* Make shared in - memory DBs possible when using the same name .
* /
var createDB = function ( ) {
var pool = { } ;
return function getOrCreate ( name ) {
if ( ! pool . hasOwnProperty ( name ) ) {
pool [ name ] = { } ;
}
return pool [ name ] ;
} ;
} ( ) ;
function MemoryContext ( db , readOnly ) {
this . readOnly = readOnly ;
this . objectStore = db ;
}
MemoryContext . prototype . clear = function ( callback ) {
if ( this . readOnly ) {
asyncCallback ( function ( ) {
callback ( "[MemoryContext] Error: write operation on read only context" ) ;
} ) ;
return ;
}
var objectStore = this . objectStore ;
Object . keys ( objectStore ) . forEach ( function ( key ) {
delete objectStore [ key ] ;
} ) ;
asyncCallback ( callback ) ;
} ;
<< << << < HEAD
function check _if _old _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
oldDirectoryData = result ;
if ( ! _ ( oldDirectoryData ) . has ( oldname ) ) {
callback ( new Errors . ENOENT ( 'a component of either path prefix does not exist' , oldname ) ) ;
} else if ( oldDirectoryData [ oldname ] . type === 'DIRECTORY' ) {
callback ( new Errors . EPERM ( 'oldpath refers to a directory' ) ) ;
} else {
find _node ( context , newParentPath , read _new _directory _data ) ;
}
}
=== === =
// Memory context doesn't care about differences between Object and Buffer
MemoryContext . prototype . getObject = MemoryContext . prototype . getBuffer = function ( key , callback ) {
var that = this ;
asyncCallback ( function ( ) {
callback ( null , that . objectStore [ key ] ) ;
} ) ;
} ;
MemoryContext . prototype . putObject = MemoryContext . prototype . putBuffer = function ( key , value , callback ) {
if ( this . readOnly ) {
asyncCallback ( function ( ) {
callback ( "[MemoryContext] Error: write operation on read only context" ) ;
} ) ;
return ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
this . objectStore [ key ] = value ;
asyncCallback ( callback ) ;
} ;
MemoryContext . prototype . delete = function ( key , callback ) {
if ( this . readOnly ) {
asyncCallback ( function ( ) {
callback ( "[MemoryContext] Error: write operation on read only context" ) ;
} ) ;
return ;
}
delete this . objectStore [ key ] ;
asyncCallback ( callback ) ;
} ;
function Memory ( name ) {
this . name = name || FILE _SYSTEM _NAME ;
}
Memory . isSupported = function ( ) {
return true ;
} ;
Memory . prototype . open = function ( callback ) {
this . db = createDB ( this . name ) ;
asyncCallback ( callback ) ;
} ;
Memory . prototype . getReadOnlyContext = function ( ) {
return new MemoryContext ( this . db , true ) ;
} ;
Memory . prototype . getReadWriteContext = function ( ) {
return new MemoryContext ( this . db , false ) ;
} ;
module . exports = Memory ;
} , { "../constants.js" : 15 , "../../lib/async.js" : 49 } ] , 18 : [ function ( require , module , exports ) {
var IndexedDB = require ( './indexeddb.js' ) ;
var WebSQL = require ( './websql.js' ) ;
var Memory = require ( './memory.js' ) ;
module . exports = {
IndexedDB : IndexedDB ,
WebSQL : WebSQL ,
Memory : Memory ,
/ * *
* Convenience Provider references
* /
<< << << < HEAD
function check _if _node _is _directory ( error , result ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
callback ( error ) ;
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
} else if ( parentDirectoryNode . type !== NODE _TYPE _DIRECTORY || ! parentDirectoryNode . data ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . ENOTDIR ( 'a component of the path prefix is not a directory' , path ) ) ;
2018-06-28 17:35:20 +00:00
=== === =
} else if ( result . mode === 'DIRECTORY' ) {
callback ( new Errors . EPERM ( 'unlink not permitted on directories' , name ) ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
} else {
2018-06-28 17:35:20 +00:00
update _file _node ( null , result ) ;
}
}
function check _if _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData = result ;
if ( ! _ ( directoryData ) . has ( name ) ) {
callback ( new Errors . ENOENT ( 'a component of the path does not name an existing file' , name ) ) ;
} else {
context . getObject ( directoryData [ name ] . id , check _if _node _is _directory ) ;
}
}
}
=== === =
// The default provider to use when none is specified
Default : IndexedDB ,
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
// The Fallback provider does automatic fallback checks
Fallback : function ( ) {
if ( IndexedDB . isSupported ( ) ) {
return IndexedDB ;
}
if ( WebSQL . isSupported ( ) ) {
return WebSQL ;
}
function NotSupported ( ) {
throw "[Filer Error] Your browser doesn't support IndexedDB or WebSQL." ;
}
NotSupported . isSupported = function ( ) {
return false ;
} ;
return NotSupported ;
} ( )
} ;
} , { "./indexeddb.js" : 50 , "./websql.js" : 51 , "./memory.js" : 52 } ] , 53 : [ function ( require , module , exports ) {
var defaults = require ( '../constants.js' ) . ENVIRONMENT ;
module . exports = function Environment ( env ) {
env = env || { } ;
env . TMP = env . TMP || defaults . TMP ;
env . PATH = env . PATH || defaults . PATH ;
this . get = function ( name ) {
return env [ name ] ;
} ;
this . set = function ( name , value ) {
env [ name ] = value ;
} ;
} ;
} , { "../constants.js" : 15 } ] , 37 : [ function ( require , module , exports ) {
var Buffer = require ( "buffer" ) . Buffer ;
// Adapt encodings to work with Buffer or Uint8Array, they expect the latter
function decode ( buf ) {
return buf . toString ( 'utf8' ) ;
}
function encode ( string ) {
return new Buffer ( string , 'utf8' ) ;
}
module . exports = {
encode : encode ,
decode : decode
} ;
} , { "buffer" : 11 } ] , 19 : [ function ( require , module , exports ) {
var Path = require ( '../path.js' ) ;
var Errors = require ( '../errors.js' ) ;
var Environment = require ( './environment.js' ) ;
var async = require ( '../../lib/async.js' ) ;
var Encoding = require ( '../encoding.js' ) ;
function Shell ( fs , options ) {
options = options || { } ;
var env = new Environment ( options . env ) ;
var cwd = '/' ;
/ * *
* The bound FileSystem ( cannot be changed )
* /
Object . defineProperty ( this , 'fs' , {
get : function get ( ) {
return fs ;
} ,
enumerable : true
} ) ;
/ * *
* The shell ' s environment ( e . g . , for things like
* path , tmp , and other env vars ) . Use env . get ( )
* and env . set ( ) to work with variables .
* /
Object . defineProperty ( this , 'env' , {
get : function get ( ) {
return env ;
} ,
enumerable : true
} ) ;
/ * *
* Change the current working directory . We
* include ` cd ` on the ` this ` vs . proto so that
* we can access cwd without exposing it externally .
* /
this . cd = function ( path , callback ) {
path = Path . resolve ( cwd , path ) ;
// Make sure the path actually exists, and is a dir
fs . stat ( path , function ( err , stats ) {
if ( err ) {
callback ( new Errors . ENOTDIR ( null , path ) ) ;
return ;
}
if ( stats . type === 'DIRECTORY' ) {
cwd = path ;
callback ( ) ;
} else {
callback ( new Errors . ENOTDIR ( null , path ) ) ;
}
} ) ;
} ;
/ * *
* Get the current working directory ( changed with ` cd() ` )
* /
this . pwd = function ( ) {
return cwd ;
} ;
}
/ * *
* Execute the . js command located at ` path ` . Such commands
* should assume the existence of 3 arguments , which will be
* defined at runtime :
*
* * fs - the current shell ' s bound filesystem object
* * args - a list of arguments for the command , or an empty list if none
* * callback - a callback function ( error , result ) to call when done .
*
* The . js command ' s contents should be the body of a function
* that looks like this :
*
* function ( fs , args , callback ) {
* // .js code here
* }
* /
Shell . prototype . exec = function ( path , args , callback ) {
/* jshint evil:true */
var sh = this ;
var fs = sh . fs ;
if ( typeof args === 'function' ) {
callback = args ;
args = [ ] ;
}
args = args || [ ] ;
callback = callback || function ( ) { } ;
path = Path . resolve ( sh . pwd ( ) , path ) ;
fs . readFile ( path , "utf8" , function ( error , data ) {
if ( error ) {
callback ( error ) ;
<< << << < HEAD
} else {
if ( node . type === NODE _TYPE _SYMBOLIC _LINK ) {
followedCount ++ ;
if ( followedCount > SYMLOOP _MAX ) {
callback ( new Errors . ELOOP ( null , path ) ) ;
} else {
follow _symbolic _link ( node . data ) ;
}
=== === =
return ;
}
try {
var cmd = new Function ( 'fs' , 'args' , 'callback' , data ) ;
cmd ( fs , args , callback ) ;
} catch ( e ) {
callback ( e ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} ) ;
} ;
/ * *
* Create a file if it does not exist , or update access and
* modified times if it does . Valid options include :
*
* * updateOnly - whether to create the file if missing ( defaults to false )
* * date - use the provided Date value instead of current date / time
* /
Shell . prototype . touch = function ( path , options , callback ) {
var sh = this ;
var fs = sh . fs ;
if ( typeof options === 'function' ) {
callback = options ;
options = { } ;
}
options = options || { } ;
callback = callback || function ( ) { } ;
path = Path . resolve ( sh . pwd ( ) , path ) ;
function createFile ( path ) {
fs . writeFile ( path , '' , callback ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function updateTimes ( path ) {
var now = Date . now ( ) ;
var atime = options . date || now ;
var mtime = options . date || now ;
fs . utimes ( path , atime , mtime , callback ) ;
}
fs . stat ( path , function ( error , stats ) {
if ( error ) {
if ( options . updateOnly === true ) {
callback ( ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
} else {
2018-06-28 17:35:20 +00:00
createFile ( path ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} else {
updateTimes ( path ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} ) ;
} ;
/ * *
* Concatenate multiple files into a single String , with each
* file separated by a newline . The ` files ` argument should
* be a String ( path to single file ) or an Array of Strings
* ( multiple file paths ) .
* /
Shell . prototype . cat = function ( files , callback ) {
var sh = this ;
var fs = sh . fs ;
var all = '' ;
callback = callback || function ( ) { } ;
if ( ! files ) {
callback ( new Errors . EINVAL ( 'Missing files argument' ) ) ;
return ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
files = typeof files === 'string' ? [ files ] : files ;
function append ( item , callback ) {
var filename = Path . resolve ( sh . pwd ( ) , item ) ;
fs . readFile ( filename , 'utf8' , function ( error , data ) {
if ( error ) {
callback ( error ) ;
return ;
}
all += data + '\n' ;
callback ( ) ;
} ) ;
}
async . eachSeries ( files , append , function ( error ) {
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
callback ( null , all . replace ( /\n$/ , '' ) ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} ) ;
} ;
/ * *
* Get the listing of a directory , returning an array of
* file entries in the following form :
*
* {
* path : < String > the basename of the directory entry
* links : < Number > the number of links to the entry
* size : < Number > the size in bytes of the entry
* modified : < Number > the last modified date / time
* type : < String > the type of the entry
* contents : < Array > an optional array of child entries
* }
*
* By default ls ( ) gives a shallow listing . If you want
* to follow directories as they are encountered , use
* the ` recursive=true ` option .
* /
Shell . prototype . ls = function ( dir , options , callback ) {
var sh = this ;
var fs = sh . fs ;
if ( typeof options === 'function' ) {
callback = options ;
options = { } ;
}
options = options || { } ;
callback = callback || function ( ) { } ;
if ( ! dir ) {
callback ( new Errors . EINVAL ( 'Missing dir argument' ) ) ;
return ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function follow _symbolic _link ( data ) {
data = normalize ( data ) ;
parentPath = dirname ( data ) ;
name = basename ( data ) ;
2018-06-25 12:27:14 +00:00
if ( ROOT _DIRECTORY _NAME === name ) {
2014-08-17 05:56:03 +00:00
context . getObject ( SUPER _NODE _ID , read _root _directory _node ) ;
2014-05-27 18:44:30 +00:00
} else {
find _node ( context , parentPath , read _parent _directory _data ) ;
}
}
2018-06-25 12:27:14 +00:00
if ( ROOT _DIRECTORY _NAME === name ) {
2014-08-17 05:56:03 +00:00
context . getObject ( SUPER _NODE _ID , read _root _directory _node ) ;
2018-06-28 17:35:20 +00:00
=== === =
function list ( path , callback ) {
var pathname = Path . resolve ( sh . pwd ( ) , path ) ;
var result = [ ] ;
fs . readdir ( pathname , function ( error , entries ) {
if ( error ) {
callback ( error ) ;
return ;
}
function getDirEntry ( name , callback ) {
name = Path . join ( pathname , name ) ;
fs . stat ( name , function ( error , stats ) {
if ( error ) {
callback ( error ) ;
return ;
}
var entry = {
path : Path . basename ( name ) ,
links : stats . nlinks ,
size : stats . size ,
modified : stats . mtime ,
type : stats . type
} ;
if ( options . recursive && stats . type === 'DIRECTORY' ) {
list ( Path . join ( pathname , entry . path ) , function ( error , items ) {
if ( error ) {
callback ( error ) ;
return ;
}
entry . contents = items ;
result . push ( entry ) ;
callback ( ) ;
} ) ;
} else {
result . push ( entry ) ;
callback ( ) ;
}
} ) ;
}
<< << << < HEAD
if ( length < 0 ) {
callback ( new Errors . EINVAL ( 'length cannot be negative' ) ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
} else {
2018-06-28 17:35:20 +00:00
ofd . getNode ( context , read _file _data ) ;
=== === =
async . eachSeries ( entries , getDirEntry , function ( error ) {
callback ( error , result ) ;
} ) ;
} ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
list ( dir , callback ) ;
} ;
2014-05-27 18:44:30 +00:00
/ * *
2018-06-28 17:35:20 +00:00
* Removes the file or directory at ` path ` . If ` path ` is a file
* it will be removed . If ` path ` is a directory , it will be
* removed if it is empty , otherwise the callback will receive
* an error . In order to remove non - empty directories , use the
* ` recursive=true ` option .
2014-05-27 18:44:30 +00:00
* /
2018-06-28 17:35:20 +00:00
Shell . prototype . rm = function ( path , options , callback ) {
var sh = this ;
var fs = sh . fs ;
if ( typeof options === 'function' ) {
callback = options ;
options = { } ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
options = options || { } ;
callback = callback || function ( ) { } ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( ! path ) {
callback ( new Errors . EINVAL ( 'Missing path argument' ) ) ;
return ;
}
2014-10-24 11:56:16 +00:00
2018-06-28 17:35:20 +00:00
function remove ( pathname , callback ) {
pathname = Path . resolve ( sh . pwd ( ) , pathname ) ;
fs . stat ( pathname , function ( error , stats ) {
if ( error ) {
callback ( error ) ;
return ;
}
<< << << < HEAD
if ( typeof atime != 'number' || typeof mtime != 'number' ) {
callback ( new Errors . EINVAL ( 'atime and mtime must be a number' ) ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
else if ( atime < 0 || mtime < 0 ) {
callback ( new Errors . EINVAL ( 'atime and mtime must be positive integers' ) ) ;
2014-05-27 18:44:30 +00:00
}
else {
2018-06-28 17:35:20 +00:00
ofd . getNode ( context , update _times ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
=== === =
// If this is a file, delete it and we're done
if ( stats . type === 'FILE' ) {
fs . unlink ( pathname , callback ) ;
return ;
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// If it's a dir, check if it's empty
fs . readdir ( pathname , function ( error , entries ) {
if ( error ) {
2014-07-14 20:01:52 +00:00
callback ( error ) ;
return ;
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
function setxattr ( error , node ) {
if ( error ) {
return callback ( error ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
set _extended _attribute ( context , path , node , name , value , flag , callback ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
if ( typeof name != 'string' ) {
callback ( new Errors . EINVAL ( 'attribute name must be a string' , path ) ) ;
}
else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' , path ) ) ;
}
else if ( flag !== null &&
flag !== XATTR _CREATE && flag !== XATTR _REPLACE ) {
callback ( new Errors . EINVAL ( 'invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE' , path ) ) ;
}
else {
find _node ( context , path , setxattr ) ;
}
}
function fsetxattr _file ( context , ofd , name , value , flag , callback ) {
function setxattr ( error , node ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-05-29 18:03:59 +00:00
Node . create ( {
guid : context . guid ,
id : superNode . rnode ,
type : NODE _TYPE _DIRECTORY
} , function ( error , result ) {
2014-07-14 20:01:52 +00:00
if ( error ) {
callback ( error ) ;
2018-06-28 17:35:20 +00:00
=== === =
return callback ( error ) ;
}
set _extended _attribute ( context , ofd . path , node , name , value , flag , callback ) ;
}
if ( typeof name !== 'string' ) {
callback ( new Errors . EINVAL ( 'attribute name must be a string' ) ) ;
}
else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' ) ) ;
}
else if ( flag !== null &&
flag !== XATTR _CREATE && flag !== XATTR _REPLACE ) {
callback ( new Errors . EINVAL ( 'invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE' ) ) ;
}
else {
ofd . getNode ( context , setxattr ) ;
=== === =
// If dir is empty, delete it and we're done
if ( entries . length === 0 ) {
fs . rmdir ( pathname , callback ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-07-14 20:01:52 +00:00
return ;
}
2018-06-28 17:35:20 +00:00
// If not, see if we're allowed to delete recursively
if ( ! options . recursive ) {
callback ( new Errors . ENOTEMPTY ( null , pathname ) ) ;
return ;
}
// Remove each dir entry recursively, then delete the dir.
entries = entries . map ( function ( filename ) {
// Root dir entries absolutely
return Path . join ( pathname , filename ) ;
} ) ;
async . eachSeries ( entries , remove , function ( error ) {
if ( error ) {
callback ( error ) ;
return ;
}
fs . rmdir ( pathname , callback ) ;
} ) ;
2014-07-14 20:01:52 +00:00
} ) ;
2018-06-28 17:35:20 +00:00
} ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
remove ( path , callback ) ;
} ;
<< << << < HEAD
function get _xattr ( error , node ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
2018-06-28 17:35:20 +00:00
return callback ( error ) ;
}
var xattrs = node . xattrs ;
if ( ! xattrs . hasOwnProperty ( name ) ) {
callback ( new Errors . ENOATTR ( null , path ) ) ;
}
else {
callback ( null , xattrs [ name ] ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
=== === =
/ * *
* Gets the path to the temporary directory , creating it if not
* present . The directory used is the one specified in
* env . TMP . The callback receives ( error , tempDirName ) .
* /
Shell . prototype . tempDir = function ( callback ) {
var sh = this ;
var fs = sh . fs ;
var tmp = sh . env . get ( 'TMP' ) ;
callback = callback || function ( ) { } ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Try and create it, and it will either work or fail
// but either way it's now there.
fs . mkdir ( tmp , function ( err ) {
callback ( null , tmp ) ;
} ) ;
} ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
/ * *
2018-06-28 17:35:20 +00:00
* Recursively creates the directory at ` path ` . If the parent
* of ` path ` does not exist , it will be created .
* Based off EnsureDir by Sam X . Xu
* https : //www.npmjs.org/package/ensureDir
* MIT License
2014-05-27 18:44:30 +00:00
* /
2018-06-28 17:35:20 +00:00
Shell . prototype . mkdirp = function ( path , callback ) {
var sh = this ;
var fs = sh . fs ;
callback = callback || function ( ) { } ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( ! path ) {
callback ( new Errors . EINVAL ( 'Missing path argument' ) ) ;
return ;
} else if ( path === '/' ) {
callback ( ) ;
return ;
}
function _mkdirp ( path , callback ) {
fs . stat ( path , function ( err , stat ) {
if ( stat ) {
if ( stat . isDirectory ( ) ) {
callback ( ) ;
return ;
} else if ( stat . isFile ( ) ) {
callback ( new Errors . ENOTDIR ( null , path ) ) ;
return ;
}
} else if ( err && err . code !== 'ENOENT' ) {
callback ( err ) ;
return ;
} else {
var parent = Path . dirname ( path ) ;
if ( parent === '/' ) {
fs . mkdir ( path , function ( err ) {
if ( err && err . code != 'EEXIST' ) {
callback ( err ) ;
return ;
}
callback ( ) ;
return ;
} ) ;
} else {
_mkdirp ( parent , function ( err ) {
if ( err ) return callback ( err ) ;
fs . mkdir ( path , function ( err ) {
if ( err && err . code != 'EEXIST' ) {
callback ( err ) ;
return ;
}
callback ( ) ;
return ;
} ) ;
} ) ;
}
}
} ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
_mkdirp ( path , callback ) ;
} ;
<< << << < HEAD
function get _xattr ( error , node ) {
if ( error ) {
return callback ( error ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
var xattrs = node . xattrs ;
if ( ! xattrs . hasOwnProperty ( name ) ) {
callback ( new Errors . ENOATTR ( ) ) ;
}
else {
callback ( null , xattrs [ name ] ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function write _directory _node ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
parentDirectoryData = result ;
2018-05-29 18:03:59 +00:00
Node . create ( {
guid : context . guid ,
type : NODE _TYPE _DIRECTORY
} , function ( error , result ) {
2014-07-14 20:01:52 +00:00
if ( error ) {
callback ( error ) ;
return ;
}
directoryNode = result ;
directoryNode . nlinks += 1 ;
2014-08-17 05:56:03 +00:00
context . putObject ( directoryNode . id , directoryNode , write _directory _data ) ;
2014-07-14 20:01:52 +00:00
} ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
if ( typeof name != 'string' ) {
callback ( new Errors . EINVAL ( ) ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' ) ) ;
}
else {
ofd . getNode ( context , get _xattr ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
module . exports = Shell ;
} , { "../path.js" : 4 , "../errors.js" : 5 , "./environment.js" : 53 , "../../lib/async.js" : 49 , "../encoding.js" : 37 } ] , 35 : [ function ( require , module , exports ) {
// Based on https://github.com/diy/intercom.js/blob/master/lib/events.js
// Copyright 2012 DIY Co Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function removeItem ( item , array ) {
for ( var i = array . length - 1 ; i >= 0 ; i -- ) {
if ( array [ i ] === item ) {
array . splice ( i , 1 ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
return array ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function update _parent _directory _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
2018-05-29 18:03:59 +00:00
parentDirectoryData [ name ] = new DirectoryEntry ( directoryNode . id , NODE _TYPE _DIRECTORY ) ;
2014-08-17 05:56:03 +00:00
context . putObject ( parentDirectoryNode . data , parentDirectoryData , update _time ) ;
2018-06-28 17:35:20 +00:00
=== === =
var EventEmitter = function EventEmitter ( ) { } ;
<< << << < HEAD
function remove _xattr ( error , node ) {
if ( error ) {
return callback ( error ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
EventEmitter . createInterface = function ( space ) {
var methods = { } ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
methods . on = function ( name , fn ) {
if ( typeof this [ space ] === 'undefined' ) {
this [ space ] = { } ;
}
<< << << < HEAD
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var xattrs = node . xattrs ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( ! xattrs . hasOwnProperty ( name ) ) {
callback ( new Errors . ENOATTR ( null , path ) ) ;
}
else {
delete xattrs [ name ] ;
context . putObject ( node . id , node , update _time ) ;
=== === =
if ( ! this [ space ] . hasOwnProperty ( name ) ) {
this [ space ] [ name ] = [ ] ;
}
this [ space ] [ name ] . push ( fn ) ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
methods . off = function ( name , fn ) {
if ( typeof this [ space ] === 'undefined' ) return ;
if ( this [ space ] . hasOwnProperty ( name ) ) {
removeItem ( fn , this [ space ] [ name ] ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function check _if _node _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
2018-06-25 12:27:14 +00:00
} else if ( ROOT _DIRECTORY _NAME === name ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EBUSY ( null , path ) ) ;
2014-05-27 18:44:30 +00:00
} else if ( ! _ ( result ) . has ( name ) ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . ENOENT ( null , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
parentDirectoryData = result ;
directoryNode = parentDirectoryData [ name ] . id ;
2014-08-17 05:56:03 +00:00
context . getObject ( directoryNode , check _if _node _is _directory ) ;
2018-06-28 17:35:20 +00:00
=== === =
methods . trigger = function ( name ) {
if ( typeof this [ space ] !== 'undefined' && this [ space ] . hasOwnProperty ( name ) ) {
var args = Array . prototype . slice . call ( arguments , 1 ) ;
for ( var i = 0 ; i < this [ space ] [ name ] . length ; i ++ ) {
this [ space ] [ name ] [ i ] . apply ( this [ space ] [ name ] [ i ] , args ) ;
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} ;
<< << << < HEAD
if ( typeof name !== 'string' ) {
callback ( new Errors . EINVAL ( 'attribute name must be a string' , path ) ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' , path ) ) ;
}
else {
find _node ( context , path , remove _xattr ) ;
}
}
=== === =
methods . removeAllListeners = function ( name ) {
if ( typeof this [ space ] === 'undefined' ) return ;
var self = this ;
self [ space ] [ name ] . forEach ( function ( fn ) {
self . off ( name , fn ) ;
} ) ;
} ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function check _if _node _is _directory ( error , result ) {
if ( error ) {
callback ( error ) ;
2018-06-25 12:27:14 +00:00
} else if ( result . type !== NODE _TYPE _DIRECTORY ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . ENOTDIR ( null , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
directoryNode = result ;
2014-08-17 05:56:03 +00:00
context . getObject ( directoryNode . data , check _if _directory _is _empty ) ;
2018-06-28 17:35:20 +00:00
=== === =
return methods ;
} ;
<< << << < HEAD
function remove _xattr ( error , node ) {
if ( error ) {
return callback ( error ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
2014-05-27 18:44:30 +00:00
} else {
2018-06-28 17:35:20 +00:00
update _node _times ( context , ofd . path , node , { ctime : Date . now ( ) } , callback ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
var xattrs = node . xattrs ;
if ( ! xattrs . hasOwnProperty ( name ) ) {
callback ( new Errors . ENOATTR ( ) ) ;
}
else {
delete xattrs [ name ] ;
context . putObject ( node . id , node , update _time ) ;
=== === =
var pvt = EventEmitter . createInterface ( '_handlers' ) ;
EventEmitter . prototype . _on = pvt . on ;
EventEmitter . prototype . _off = pvt . off ;
EventEmitter . prototype . _trigger = pvt . trigger ;
var pub = EventEmitter . createInterface ( 'handlers' ) ;
EventEmitter . prototype . on = function ( ) {
pub . on . apply ( this , arguments ) ;
Array . prototype . unshift . call ( arguments , 'on' ) ;
this . _trigger . apply ( this , arguments ) ;
} ;
EventEmitter . prototype . off = pub . off ;
EventEmitter . prototype . trigger = pub . trigger ;
EventEmitter . prototype . removeAllListeners = pub . removeAllListeners ;
module . exports = EventEmitter ;
} , { } ] , 16 : [ function ( require , module , exports ) {
var global = arguments [ 3 ] ;
var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ;
// Based on https://github.com/diy/intercom.js/blob/master/lib/intercom.js
// Copyright 2012 DIY Co Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
var EventEmitter = require ( './eventemitter.js' ) ;
var guid = require ( '../src/shared.js' ) . guid ;
function throttle ( delay , fn ) {
var last = 0 ;
return function ( ) {
var now = Date . now ( ) ;
if ( now - last > delay ) {
last = now ;
fn . apply ( this , arguments ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function extend ( a , b ) {
if ( typeof a === 'undefined' || ! a ) {
a = { } ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
else {
ofd . getNode ( context , remove _xattr ) ;
=== === =
if ( ( typeof b === 'undefined' ? 'undefined' : _typeof ( b ) ) === 'object' ) {
for ( var key in b ) {
if ( b . hasOwnProperty ( key ) ) {
a [ key ] = b [ key ] ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
return a ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var localStorage = function ( window ) {
if ( typeof window === 'undefined' || typeof window . localStorage === 'undefined' ) {
return {
getItem : function getItem ( ) { } ,
setItem : function setItem ( ) { } ,
removeItem : function removeItem ( ) { }
} ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
return window . localStorage ;
} ( global ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function Intercom ( ) {
var self = this ;
var now = Date . now ( ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
this . origin = guid ( ) ;
this . lastMessage = now ;
this . receivedIDs = { } ;
this . previousValues = { } ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var storageHandler = function storageHandler ( ) {
self . _onStorageEvent . apply ( self , arguments ) ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// If we're in node.js, skip event registration
if ( typeof document === 'undefined' ) {
return ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-06-25 12:27:14 +00:00
if ( ROOT _DIRECTORY _NAME === name ) {
2014-05-27 18:44:30 +00:00
if ( _ ( flags ) . contains ( O _WRITE ) ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EISDIR ( 'the named file is a directory and O_WRITE is set' , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
find _node ( context , path , set _file _node ) ;
}
2018-06-28 17:35:20 +00:00
=== === =
if ( document . attachEvent ) {
document . attachEvent ( 'onstorage' , storageHandler ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
} else {
2018-06-28 17:35:20 +00:00
global . addEventListener ( 'storage' , storageHandler , false ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function read _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
2018-05-29 18:03:59 +00:00
} else if ( result . type !== NODE _TYPE _DIRECTORY ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . ENOENT ( null , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
directoryNode = result ;
2014-08-17 05:56:03 +00:00
context . getObject ( directoryNode . data , check _if _file _exists ) ;
2018-06-28 17:35:20 +00:00
=== === =
Intercom . prototype . _transaction = function ( fn ) {
var TIMEOUT = 1000 ;
var WAIT = 20 ;
var self = this ;
var executed = false ;
var listening = false ;
var waitTimer = null ;
function lock ( ) {
if ( executed ) {
return ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function check _if _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData = result ;
if ( _ ( directoryData ) . has ( name ) ) {
if ( _ ( flags ) . contains ( O _EXCLUSIVE ) ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . ENOENT ( 'O_CREATE and O_EXCLUSIVE are set, and the named file exists' , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
directoryEntry = directoryData [ name ] ;
2018-06-25 12:27:14 +00:00
if ( directoryEntry . type === NODE _TYPE _DIRECTORY && _ ( flags ) . contains ( O _WRITE ) ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EISDIR ( 'the named file is a directory and O_WRITE is set' , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
2014-08-17 05:56:03 +00:00
context . getObject ( directoryEntry . id , check _if _symbolic _link ) ;
2014-05-27 18:44:30 +00:00
}
}
} else {
if ( ! _ ( flags ) . contains ( O _CREATE ) ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . ENOENT ( 'O_CREATE is not set and the named file does not exist' , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
write _file _node ( ) ;
}
2018-06-28 17:35:20 +00:00
=== === =
var now = Date . now ( ) ;
var activeLock = localStorage . getItem ( INDEX _LOCK ) | 0 ;
if ( activeLock && now - activeLock < TIMEOUT ) {
if ( ! listening ) {
self . _on ( 'storage' , lock ) ;
listening = true ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
waitTimer = setTimeout ( lock , WAIT ) ;
return ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
executed = true ;
localStorage . setItem ( INDEX _LOCK , now ) ;
fn ( ) ;
unlock ( ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function check _if _symbolic _link ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
var node = result ;
2018-06-25 12:27:14 +00:00
if ( node . type === NODE _TYPE _SYMBOLIC _LINK ) {
2014-05-27 18:44:30 +00:00
followedCount ++ ;
if ( followedCount > SYMLOOP _MAX ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . ELOOP ( null , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
follow _symbolic _link ( node . data ) ;
}
} else {
set _file _node ( undefined , node ) ;
}
2018-06-28 17:35:20 +00:00
=== === =
function unlock ( ) {
if ( listening ) {
self . _off ( 'storage' , lock ) ;
}
if ( waitTimer ) {
clearTimeout ( waitTimer ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
localStorage . removeItem ( INDEX _LOCK ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function follow _symbolic _link ( data ) {
data = normalize ( data ) ;
parentPath = dirname ( data ) ;
name = basename ( data ) ;
2018-06-25 12:27:14 +00:00
if ( ROOT _DIRECTORY _NAME === name ) {
2014-05-27 18:44:30 +00:00
if ( _ ( flags ) . contains ( O _WRITE ) ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EISDIR ( 'the named file is a directory and O_WRITE is set' , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
find _node ( context , path , set _file _node ) ;
2018-06-28 17:35:20 +00:00
=== === =
lock ( ) ;
} ;
Intercom . prototype . _cleanup _emit = throttle ( 100 , function ( ) {
var self = this ;
self . _transaction ( function ( ) {
var now = Date . now ( ) ;
var threshold = now - THRESHOLD _TTL _EMIT ;
var changed = 0 ;
var messages ;
<< << << < HEAD
function mkdir ( fs , context , path , mode , callback ) {
// NOTE: we support passing a mode arg, but we ignore it internally for now.
callback = arguments [ arguments . length - 1 ] ;
if ( ! pathCheck ( path , callback ) ) return ;
make _directory ( context , path , callback ) ;
}
function rmdir ( fs , context , path , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
remove _directory ( context , path , callback ) ;
}
=== === =
try {
messages = JSON . parse ( localStorage . getItem ( INDEX _EMIT ) || '[]' ) ;
} catch ( e ) {
messages = [ ] ;
}
for ( var i = messages . length - 1 ; i >= 0 ; i -- ) {
if ( messages [ i ] . timestamp < threshold ) {
messages . splice ( i , 1 ) ;
changed ++ ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
if ( changed > 0 ) {
localStorage . setItem ( INDEX _EMIT , JSON . stringify ( messages ) ) ;
}
} ) ;
} ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Intercom . prototype . _cleanup _once = throttle ( 100 , function ( ) {
var self = this ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
self . _transaction ( function ( ) {
var timestamp , ttl , key ;
var table ;
var now = Date . now ( ) ;
var changed = 0 ;
try {
table = JSON . parse ( localStorage . getItem ( INDEX _ONCE ) || '{}' ) ;
} catch ( e ) {
table = { } ;
}
for ( key in table ) {
if ( self . _once _expired ( key , table ) ) {
delete table [ key ] ;
changed ++ ;
}
}
if ( changed > 0 ) {
localStorage . setItem ( INDEX _ONCE , JSON . stringify ( table ) ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} ) ;
} ) ;
Intercom . prototype . _once _expired = function ( key , table ) {
if ( ! table ) {
return true ;
}
if ( ! table . hasOwnProperty ( key ) ) {
return true ;
}
if ( _typeof ( table [ key ] ) !== 'object' ) {
return true ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function write _file _node ( ) {
2018-05-29 18:03:59 +00:00
Node . create ( {
guid : context . guid ,
type : NODE _TYPE _FILE
} , function ( error , result ) {
2014-07-14 20:01:52 +00:00
if ( error ) {
callback ( error ) ;
return ;
}
fileNode = result ;
fileNode . nlinks += 1 ;
2014-08-17 05:56:03 +00:00
context . putObject ( fileNode . id , fileNode , write _file _data ) ;
2014-07-14 20:01:52 +00:00
} ) ;
2018-06-28 17:35:20 +00:00
=== === =
var ttl = table [ key ] . ttl || THRESHOLD _TTL _ONCE ;
var now = Date . now ( ) ;
var timestamp = table [ key ] . timestamp ;
return timestamp < now - ttl ;
} ;
Intercom . prototype . _localStorageChanged = function ( event , field ) {
if ( event && event . key ) {
return event . key === field ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
var currentValue = localStorage . getItem ( field ) ;
if ( currentValue === this . previousValues [ field ] ) {
return false ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
this . previousValues [ field ] = currentValue ;
return true ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
function link ( fs , context , oldpath , newpath , callback ) {
if ( ! pathCheck ( oldpath , callback ) ) return ;
if ( ! pathCheck ( newpath , callback ) ) return ;
link _node ( context , oldpath , newpath , callback ) ;
}
function unlink ( fs , context , path , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
unlink _node ( context , path , callback ) ;
}
=== === =
Intercom . prototype . _onStorageEvent = function ( event ) {
event = event || global . event ;
var self = this ;
if ( this . _localStorageChanged ( event , INDEX _EMIT ) ) {
this . _transaction ( function ( ) {
2014-05-27 18:44:30 +00:00
var now = Date . now ( ) ;
2018-06-28 17:35:20 +00:00
var data = localStorage . getItem ( INDEX _EMIT ) ;
var messages ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
try {
messages = JSON . parse ( data || '[]' ) ;
} catch ( e ) {
messages = [ ] ;
}
for ( var i = 0 ; i < messages . length ; i ++ ) {
if ( messages [ i ] . origin === self . origin ) continue ;
if ( messages [ i ] . timestamp < self . lastMessage ) continue ;
if ( messages [ i ] . id ) {
if ( self . receivedIDs . hasOwnProperty ( messages [ i ] . id ) ) continue ;
self . receivedIDs [ messages [ i ] . id ] = true ;
}
self . trigger ( messages [ i ] . name , messages [ i ] . payload ) ;
}
self . lastMessage = now ;
} ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function update _directory _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
2018-05-29 18:03:59 +00:00
directoryData [ name ] = new DirectoryEntry ( fileNode . id , NODE _TYPE _FILE ) ;
2014-08-17 05:56:03 +00:00
context . putObject ( directoryNode . data , directoryData , update _time ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
=== === =
this . _trigger ( 'storage' , event ) ;
} ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else if ( ! _ ( ofd . flags ) . contains ( O _READ ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit reading' ) ) ;
} else {
read _data ( context , ofd , buffer , offset , length , position , wrapped _cb ) ;
=== === =
Intercom . prototype . _emit = function ( name , message , id ) {
id = typeof id === 'string' || typeof id === 'number' ? String ( id ) : null ;
if ( id && id . length ) {
if ( this . receivedIDs . hasOwnProperty ( id ) ) return ;
this . receivedIDs [ id ] = true ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
var packet = {
id : id ,
name : name ,
origin : this . origin ,
timestamp : Date . now ( ) ,
payload : message
} ;
var self = this ;
this . _transaction ( function ( ) {
var data = localStorage . getItem ( INDEX _EMIT ) || '[]' ;
var delimiter = data === '[]' ? '' : ',' ;
data = [ data . substring ( 0 , data . length - 1 ) , delimiter , JSON . stringify ( packet ) , ']' ] . join ( '' ) ;
localStorage . setItem ( INDEX _EMIT , data ) ;
self . trigger ( name , message ) ;
setTimeout ( function ( ) {
self . _cleanup _emit ( ) ;
} , 50 ) ;
} ) ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Intercom . prototype . emit = function ( name , message ) {
this . _emit . apply ( this , arguments ) ;
this . _trigger ( 'emit' , name , message ) ;
} ;
Intercom . prototype . once = function ( key , fn , ttl ) {
if ( ! Intercom . supported ) {
return ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
var self = this ;
this . _transaction ( function ( ) {
var data ;
try {
data = JSON . parse ( localStorage . getItem ( INDEX _ONCE ) || '{}' ) ;
} catch ( e ) {
data = { } ;
}
if ( ! self . _once _expired ( key , data ) ) {
return ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
data [ key ] = { } ;
data [ key ] . timestamp = Date . now ( ) ;
if ( typeof ttl === 'number' ) {
data [ key ] . ttl = ttl * 1000 ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
localStorage . setItem ( INDEX _ONCE , JSON . stringify ( data ) ) ;
fn ( ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
setTimeout ( function ( ) {
self . _cleanup _once ( ) ;
} , 50 ) ;
} ) ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
extend ( Intercom . prototype , EventEmitter . prototype ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Intercom . supported = typeof localStorage !== 'undefined' ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var INDEX _EMIT = 'intercom' ;
var INDEX _ONCE = 'intercom_once' ;
var INDEX _LOCK = 'intercom_lock' ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var THRESHOLD _TTL _EMIT = 50000 ;
var THRESHOLD _TTL _ONCE = 1000 * 3600 ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Intercom . destroy = function ( ) {
localStorage . removeItem ( INDEX _LOCK ) ;
localStorage . removeItem ( INDEX _EMIT ) ;
localStorage . removeItem ( INDEX _ONCE ) ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else if ( ! _ ( ofd . flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit writing' ) ) ;
} else if ( buffer . length - offset < length ) {
callback ( new Errors . EIO ( 'intput buffer is too small' ) ) ;
} else {
write _data ( context , ofd , buffer , offset , length , position , callback ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
=== === =
Intercom . getInstance = function ( ) {
var intercom ;
return function ( ) {
if ( ! intercom ) {
intercom = new Intercom ( ) ;
}
return intercom ;
} ;
} ( ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
module . exports = Intercom ;
} , { "./eventemitter.js" : 35 , "../src/shared.js" : 14 } ] , 17 : [ function ( require , module , exports ) {
var EventEmitter = require ( '../lib/eventemitter.js' ) ;
var Path = require ( './path.js' ) ;
var Intercom = require ( '../lib/intercom.js' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
/ * *
* FSWatcher based on node . js ' FSWatcher
* see https : //github.com/joyent/node/blob/master/lib/fs.js
* /
function FSWatcher ( ) {
EventEmitter . call ( this ) ;
var self = this ;
var recursive = false ;
var recursivePathPrefix ;
var filename ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function onchange ( path ) {
// Watch for exact filename, or parent path when recursive is true.
if ( filename === path || recursive && path . indexOf ( recursivePathPrefix ) === 0 ) {
self . trigger ( 'change' , 'change' , path ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
// We support, but ignore the second arg, which node.js uses.
self . start = function ( filename _ , persistent _ , recursive _ ) {
// Bail if we've already started (and therefore have a filename);
if ( filename ) {
return ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
if ( Path . isNull ( filename _ ) ) {
throw new Error ( 'Path must be a string without null bytes.' ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// TODO: get realpath for symlinks on filename...
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Filer's Path.normalize strips trailing slashes, which we use here.
// See https://github.com/js-platform/filer/issues/105
filename = Path . normalize ( filename _ ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function read _file _data ( error , result ) {
if ( error ) {
callback ( error ) ;
2018-05-29 18:03:59 +00:00
} else if ( result . type === NODE _TYPE _DIRECTORY ) {
2014-12-02 18:45:21 +00:00
callback ( new Errors . EISDIR ( 'the named file is a directory' , ofd . path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
fileNode = result ;
2014-08-17 05:56:03 +00:00
context . getBuffer ( fileNode . data , handle _file _data ) ;
2018-06-28 17:35:20 +00:00
=== === =
// Whether to watch beneath this path or not
recursive = recursive _ === true ;
// If recursive, construct a path prefix portion for comparisons later
// (i.e., '/path' becomes '/path/' so we can search within a filename for the
// prefix). We also take care to allow for '/' on its own.
if ( recursive ) {
recursivePathPrefix = filename === '/' ? '/' : filename + '/' ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
var intercom = Intercom . getInstance ( ) ;
intercom . on ( 'change' , onchange ) ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
self . close = function ( ) {
var intercom = Intercom . getInstance ( ) ;
intercom . off ( 'change' , onchange ) ;
self . removeAllListeners ( 'change' ) ;
} ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
FSWatcher . prototype = new EventEmitter ( ) ;
FSWatcher . prototype . constructor = FSWatcher ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
module . exports = FSWatcher ;
} , { "../lib/eventemitter.js" : 35 , "./path.js" : 4 , "../lib/intercom.js" : 16 } ] , 38 : [ function ( require , module , exports ) {
var MODE _FILE = require ( './constants.js' ) . MODE _FILE ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
module . exports = function DirectoryEntry ( id , type ) {
this . id = id ;
this . type = type || MODE _FILE ;
} ;
} , { "./constants.js" : 15 } ] , 39 : [ function ( require , module , exports ) {
module . exports = function OpenFileDescription ( path , id , flags , position ) {
this . path = path ;
this . id = id ;
this . flags = flags ;
this . position = position ;
} ;
} , { } ] , 40 : [ function ( require , module , exports ) {
var Constants = require ( './constants.js' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-06-25 12:27:14 +00:00
if ( ROOT _DIRECTORY _NAME === name ) {
2018-06-28 17:35:20 +00:00
find _node ( context , path , callback ) ;
} else {
find _node ( context , parentPath , read _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
function SuperNode ( options ) {
var now = Date . now ( ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
this . id = Constants . SUPER _NODE _ID ;
this . mode = Constants . MODE _META ;
this . atime = options . atime || now ;
this . ctime = options . ctime || now ;
this . mtime = options . mtime || now ;
// root node id (randomly generated)
this . rnode = options . rnode ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
SuperNode . create = function ( options , callback ) {
options . guid ( function ( err , rnode ) {
if ( err ) {
callback ( err ) ;
return ;
}
options . rnode = options . rnode || rnode ;
callback ( null , new SuperNode ( options ) ) ;
} ) ;
} ;
module . exports = SuperNode ;
} , { "./constants.js" : 15 } ] , 41 : [ function ( require , module , exports ) {
var MODE _FILE = require ( './constants.js' ) . MODE _FILE ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
newpath = normalize ( newpath ) ;
var newname = basename ( newpath ) ;
var newParentPath = dirname ( newpath ) ;
2018-05-29 18:03:59 +00:00
var ctime = Date . now ( ) ;
2014-05-27 18:44:30 +00:00
var oldDirectoryNode ;
var oldDirectoryData ;
var newDirectoryNode ;
var newDirectoryData ;
2018-05-29 18:03:59 +00:00
var fileNodeID ;
2014-05-27 18:44:30 +00:00
var fileNode ;
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
} else {
2018-05-29 18:03:59 +00:00
update _node _times ( context , newpath , fileNode , { ctime : ctime } , callback ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
function Node ( options ) {
var now = Date . now ( ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
this . id = options . id ;
this . mode = options . mode || MODE _FILE ; // node type (file, directory, etc)
this . size = options . size || 0 ; // size (bytes for files, entries for directories)
this . atime = options . atime || now ; // access time (will mirror ctime after creation)
this . ctime = options . ctime || now ; // creation/change time
this . mtime = options . mtime || now ; // modified time
this . flags = options . flags || [ ] ; // file flags
this . xattrs = options . xattrs || { } ; // extended attributes
this . nlinks = options . nlinks || 0 ; // links count
this . version = options . version || 0 ; // node version
this . blksize = undefined ; // block size
this . nblocks = 1 ; // blocks count
this . data = options . data ; // id for data object
}
// Make sure the options object has an id on property,
// either from caller or one we generate using supplied guid fn.
function ensureID ( options , prop , callback ) {
if ( options [ prop ] ) {
callback ( null ) ;
} else {
options . guid ( function ( err , id ) {
options [ prop ] = id ;
callback ( err ) ;
} ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
function getxattr ( fs , context , path , name , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
getxattr _file ( context , path , name , callback ) ;
}
<< << << < HEAD
2018-05-29 18:03:59 +00:00
function read _file _node ( error , result ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
callback ( error ) ;
} else {
2018-05-29 18:03:59 +00:00
context . getObject ( fileNodeID , update _file _node ) ;
2014-05-27 18:44:30 +00:00
}
}
function check _if _new _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
newDirectoryData = result ;
if ( _ ( newDirectoryData ) . has ( newname ) ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EEXIST ( 'newpath resolves to an existing file' , newname ) ) ;
2014-05-27 18:44:30 +00:00
} else {
newDirectoryData [ newname ] = oldDirectoryData [ oldname ] ;
2018-05-29 18:03:59 +00:00
fileNodeID = newDirectoryData [ newname ] . id ;
context . putObject ( newDirectoryNode . data , newDirectoryData , read _file _node ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
=== === =
function fgetxattr ( fs , context , fd , name , callback ) {
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
else {
fgetxattr _file ( context , ofd , name , callback ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
=== === =
Node . create = function ( options , callback ) {
// We expect both options.id and options.data to be provided/generated.
ensureID ( options , 'id' , function ( err ) {
if ( err ) {
callback ( err ) ;
return ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function check _if _old _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
oldDirectoryData = result ;
if ( ! _ ( oldDirectoryData ) . has ( oldname ) ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . ENOENT ( 'a component of either path prefix does not exist' , oldname ) ) ;
2018-05-29 18:03:59 +00:00
} else if ( oldDirectoryData [ oldname ] . type === NODE _TYPE _DIRECTORY ) {
2015-05-12 19:44:26 +00:00
callback ( new Errors . EPERM ( 'oldpath refers to a directory' ) ) ;
2014-05-27 18:44:30 +00:00
} else {
find _node ( context , newParentPath , read _new _directory _data ) ;
2018-06-28 17:35:20 +00:00
=== === =
ensureID ( options , 'data' , function ( err ) {
if ( err ) {
callback ( err ) ;
return ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
callback ( null , new Node ( options ) ) ;
} ) ;
} ) ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
if ( ! pathCheck ( path , callback ) ) return ;
setxattr _file ( context , path , name , value , flag , callback ) ;
=== === =
module . exports = Node ;
} , { "./constants.js" : 15 } ] , 42 : [ function ( require , module , exports ) {
var Constants = require ( './constants.js' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function Stats ( fileNode , devName ) {
this . node = fileNode . id ;
this . dev = devName ;
this . size = fileNode . size ;
this . nlinks = fileNode . nlinks ;
this . atime = fileNode . atime ;
this . mtime = fileNode . mtime ;
this . ctime = fileNode . ctime ;
this . type = fileNode . mode ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
Stats . prototype . isFile = function ( ) {
return this . type === Constants . MODE _FILE ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
else if ( ! _ ( ofd . flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit writing' ) ) ;
}
else {
fsetxattr _file ( context , ofd , name , value , flag , callback ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function removexattr ( fs , context , path , name , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
removexattr _file ( context , path , name , callback ) ;
}
function fremovexattr ( fs , context , fd , name , callback ) {
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
else if ( ! _ ( ofd . flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit writing' ) ) ;
}
<< << << < HEAD
2014-05-27 18:44:30 +00:00
2014-09-30 20:16:15 +00:00
function check _if _node _is _directory ( error , result ) {
if ( error ) {
callback ( error ) ;
2018-05-29 18:03:59 +00:00
} else if ( result . type === NODE _TYPE _DIRECTORY ) {
2014-09-30 20:16:15 +00:00
callback ( new Errors . EPERM ( 'unlink not permitted on directories' , name ) ) ;
} else {
update _file _node ( null , result ) ;
}
2018-06-28 17:35:20 +00:00
=== === =
else {
fremovexattr _file ( context , ofd , name , callback ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-09-30 20:16:15 +00:00
}
2018-06-28 17:35:20 +00:00
}
=== === =
Stats . prototype . isDirectory = function ( ) {
return this . type === Constants . MODE _DIRECTORY ;
} ;
2014-09-30 20:16:15 +00:00
2018-06-28 17:35:20 +00:00
Stats . prototype . isSymbolicLink = function ( ) {
return this . type === Constants . MODE _SYMBOLIC _LINK ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// These will always be false in Filer.
Stats . prototype . isSocket = Stats . prototype . isFIFO = Stats . prototype . isCharacterDevice = Stats . prototype . isBlockDevice = function ( ) {
return false ;
} ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
module . exports = Stats ;
} , { "./constants.js" : 15 } ] , 20 : [ function ( require , module , exports ) {
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var _ = require ( '../../lib/nodash.js' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var Path = require ( '../path.js' ) ;
var normalize = Path . normalize ;
var dirname = Path . dirname ;
var basename = Path . basename ;
var isAbsolutePath = Path . isAbsolute ;
var isNullPath = Path . isNull ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function read _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
2018-05-29 18:03:59 +00:00
} else if ( result . type !== NODE _TYPE _DIRECTORY ) {
2014-08-20 19:57:09 +00:00
callback ( new Errors . ENOTDIR ( null , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
directoryNode = result ;
2014-08-17 05:56:03 +00:00
context . getObject ( directoryNode . data , handle _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
=== === =
var Constants = require ( '../constants.js' ) ;
var MODE _FILE = Constants . MODE _FILE ;
var MODE _DIRECTORY = Constants . MODE _DIRECTORY ;
var MODE _SYMBOLIC _LINK = Constants . MODE _SYMBOLIC _LINK ;
var MODE _META = Constants . MODE _META ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var ROOT _DIRECTORY _NAME = Constants . ROOT _DIRECTORY _NAME ;
var SUPER _NODE _ID = Constants . SUPER _NODE _ID ;
var SYMLOOP _MAX = Constants . SYMLOOP _MAX ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var O _READ = Constants . O _READ ;
var O _WRITE = Constants . O _WRITE ;
var O _CREATE = Constants . O _CREATE ;
var O _EXCLUSIVE = Constants . O _EXCLUSIVE ;
var O _TRUNCATE = Constants . O _TRUNCATE ;
var O _APPEND = Constants . O _APPEND ;
var O _FLAGS = Constants . O _FLAGS ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var XATTR _CREATE = Constants . XATTR _CREATE ;
var XATTR _REPLACE = Constants . XATTR _REPLACE ;
var FS _NOMTIME = Constants . FS _NOMTIME ;
var FS _NOCTIME = Constants . FS _NOCTIME ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-06-25 12:27:14 +00:00
if ( ROOT _DIRECTORY _NAME === name ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EEXIST ( null , name ) ) ;
2014-05-27 18:44:30 +00:00
} else {
find _node ( context , parentPath , read _directory _data ) ;
}
2018-06-28 17:35:20 +00:00
=== === =
var Encoding = require ( '../encoding.js' ) ;
var Errors = require ( '../errors.js' ) ;
var DirectoryEntry = require ( '../directory-entry.js' ) ;
var OpenFileDescription = require ( '../open-file-description.js' ) ;
var SuperNode = require ( '../super-node.js' ) ;
var Node = require ( '../node.js' ) ;
var Stats = require ( '../stats.js' ) ;
var Buffer = require ( '../buffer.js' ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
/ * *
* Many functions below use this callback pattern . If it ' s not
* re - defined , we use this to generate a callback . NOTE : this
* can be use for callbacks of both forms without problem ( i . e . ,
* since result will be undefined if not returned ) :
* - callback ( error )
* - callback ( error , result )
* /
function standard _check _result _cb ( callback ) {
return function ( error , result ) {
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
callback ( null , result ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} ;
}
/ * *
* Update node times . Only passed times are modified ( undefined times are ignored )
* and filesystem flags are examined in order to override update logic .
* /
function update _node _times ( context , path , node , times , callback ) {
// Honour mount flags for how we update times
var flags = context . flags ;
if ( _ ( flags ) . contains ( FS _NOCTIME ) ) {
delete times . ctime ;
}
if ( _ ( flags ) . contains ( FS _NOMTIME ) ) {
delete times . mtime ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function write _file _node ( ) {
2018-05-29 18:03:59 +00:00
Node . create ( {
guid : context . guid ,
type : NODE _TYPE _SYMBOLIC _LINK
} , function ( error , result ) {
2014-07-14 20:01:52 +00:00
if ( error ) {
callback ( error ) ;
return ;
}
fileNode = result ;
fileNode . nlinks += 1 ;
2018-05-29 18:03:59 +00:00
// If the srcpath isn't absolute, resolve it relative to the dstpath
// but store both versions, since we'll use the relative one in readlink().
if ( ! isAbsolutePath ( srcpath ) ) {
fileNode . symlink _relpath = srcpath ;
srcpath = Path . resolve ( parentPath , srcpath ) ;
}
2014-07-14 20:01:52 +00:00
fileNode . size = srcpath . length ;
fileNode . data = srcpath ;
2018-05-29 18:03:59 +00:00
2014-08-17 05:56:03 +00:00
context . putObject ( fileNode . id , fileNode , update _directory _data ) ;
2014-07-14 20:01:52 +00:00
} ) ;
2018-06-28 17:35:20 +00:00
=== === =
// Only do the update if required (i.e., times are still present)
var update = false ;
if ( times . ctime ) {
node . ctime = times . ctime ;
// We don't do atime tracking for perf reasons, but do mirror ctime
node . atime = times . ctime ;
update = true ;
}
if ( times . atime ) {
// The only time we explicitly pass atime is when utimes(), futimes() is called.
// Override ctime mirror here if so
node . atime = times . atime ;
update = true ;
}
if ( times . mtime ) {
node . mtime = times . mtime ;
update = true ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function complete ( error ) {
// Queue this change so we can send watch events.
// Unlike node.js, we send the full path vs. basename/dirname only.
context . changes . push ( { event : 'change' , path : path } ) ;
callback ( error ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function update _directory _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
2018-05-29 18:03:59 +00:00
directoryData [ name ] = new DirectoryEntry ( fileNode . id , NODE _TYPE _SYMBOLIC _LINK ) ;
2014-08-17 05:56:03 +00:00
context . putObject ( directoryNode . data , directoryData , update _time ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
if ( update ) {
context . putObject ( node . id , node , complete ) ;
} else {
complete ( ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
function readdir ( fs , context , path , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
read _directory ( context , path , callback ) ;
}
=== === =
/ * *
* make _node ( )
* /
// in: file or directory path
// out: new node representing file/directory
function make _node ( context , path , mode , callback ) {
if ( mode !== MODE _DIRECTORY && mode !== MODE _FILE ) {
return callback ( new Errors . EINVAL ( 'mode must be a directory or file' , path ) ) ;
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
path = normalize ( path ) ;
2018-06-28 17:35:20 +00:00
2014-05-27 18:44:30 +00:00
var name = basename ( path ) ;
var parentPath = dirname ( path ) ;
2018-06-28 17:35:20 +00:00
var parentNode ;
var parentNodeData ;
var node ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
utimes _file ( context , path , atime , mtime , callback ) ;
}
=== === =
// Check if the parent node exists
function create _node _in _parent ( error , parentDirectoryNode ) {
if ( error ) {
callback ( error ) ;
} else if ( parentDirectoryNode . mode !== MODE _DIRECTORY ) {
callback ( new Errors . ENOTDIR ( 'a component of the path prefix is not a directory' , path ) ) ;
} else {
parentNode = parentDirectoryNode ;
find _node ( context , path , check _if _node _exists ) ;
}
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Check if the node to be created already exists
function check _if _node _exists ( error , result ) {
if ( ! error && result ) {
callback ( new Errors . EEXIST ( 'path name already exists' , path ) ) ;
} else if ( error && ! ( error instanceof Errors . ENOENT ) ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
context . getObject ( parentNode . data , create _node ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else if ( ! _ ( ofd . flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit writing' ) ) ;
} else {
futimes _file ( context , ofd , atime , mtime , callback ) ;
=== === =
// Create the new node
function create _node ( error , result ) {
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
parentNodeData = result ;
Node . create ( { guid : context . guid , mode : mode } , function ( error , result ) {
if ( error ) {
callback ( error ) ;
return ;
}
node = result ;
node . nlinks += 1 ;
context . putObject ( node . id , node , update _parent _node _data ) ;
} ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
function check _if _symbolic ( error , fileNode ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
callback ( error ) ;
} else {
2018-06-25 12:27:14 +00:00
if ( fileNode . type !== NODE _TYPE _SYMBOLIC _LINK ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EINVAL ( 'path not a symbolic link' , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
2018-05-29 18:03:59 +00:00
// If we were originally given a relative path, return that now vs. the
// absolute path we've generated and use elsewhere internally.
var target = fileNode . symlink _relpath ? fileNode . symlink _relpath : fileNode . data ;
callback ( null , target ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
// Update parent node time
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
} else {
var now = Date . now ( ) ;
update _node _times ( context , parentPath , node , { mtime : now , ctime : now } , callback ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
oldpath = normalize ( oldpath ) ;
newpath = normalize ( newpath ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function read _file _data ( error , node ) {
if ( error ) {
callback ( error ) ;
2018-06-25 12:27:14 +00:00
} else if ( node . type === NODE _TYPE _DIRECTORY ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EISDIR ( null , path ) ) ;
2014-05-27 18:44:30 +00:00
} else {
fileNode = node ;
2014-08-17 05:56:03 +00:00
context . getBuffer ( fileNode . data , truncate _file _data ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
=== === =
var oldParentPath = Path . dirname ( oldpath ) ;
var newParentPath = Path . dirname ( oldpath ) ;
var oldName = Path . basename ( oldpath ) ;
var newName = Path . basename ( newpath ) ;
var oldParentDirectory , oldParentData ;
var newParentDirectory , newParentData ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function update _times ( error , newNode ) {
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
update _node _times ( context , newpath , newNode , { ctime : Date . now ( ) } , callback ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function read _new _directory ( error ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
context . getObject ( newParentData [ newName ] . id , update _times ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function update _old _parent _directory _data ( error ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
if ( oldParentDirectory . id === newParentDirectory . id ) {
oldParentData = newParentData ;
}
delete oldParentData [ oldName ] ;
context . putObject ( oldParentDirectory . data , oldParentData , read _new _directory ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function update _new _parent _directory _data ( error ) {
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-06-25 12:27:14 +00:00
} else if ( node . type === NODE _TYPE _DIRECTORY ) {
2014-05-27 18:44:30 +00:00
callback ( new Errors . EISDIR ( ) ) ;
} else {
fileNode = node ;
2014-08-17 05:56:03 +00:00
context . getBuffer ( fileNode . data , truncate _file _data ) ;
2018-06-28 17:35:20 +00:00
=== === =
} else {
newParentData [ newName ] = oldParentData [ oldName ] ;
context . putObject ( newParentDirectory . data , newParentData , update _old _parent _directory _data ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function check _if _new _directory _exists ( error , result ) {
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
newParentData = result ;
if ( _ ( newParentData ) . has ( newName ) ) {
remove _directory ( context , newpath , update _new _parent _directory _data ) ;
2014-06-09 14:40:50 +00:00
} else {
2018-06-28 17:35:20 +00:00
update _new _parent _directory _data ( ) ;
2014-05-27 18:44:30 +00:00
}
}
}
2018-06-28 17:35:20 +00:00
function read _new _parent _directory _data ( error , result ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
newParentDirectory = result ;
context . getObject ( newParentDirectory . data , check _if _new _directory _exists ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function get _new _parent _directory ( error , result ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
oldParentData = result ;
find _node ( context , newParentPath , read _new _parent _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function read _parent _directory _data ( error , result ) {
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
oldParentDirectory = result ;
context . getObject ( result . data , get _new _parent _directory ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-06-25 12:27:14 +00:00
if ( typeof atime !== 'number' || typeof mtime !== 'number' ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EINVAL ( 'atime and mtime must be number' , path ) ) ;
2014-05-27 18:44:30 +00:00
}
else if ( atime < 0 || mtime < 0 ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EINVAL ( 'atime and mtime must be positive integers' , path ) ) ;
2014-05-27 18:44:30 +00:00
}
else {
find _node ( context , path , update _times ) ;
2018-06-28 17:35:20 +00:00
=== === =
function unlink _old _file ( error ) {
if ( error ) {
callback ( error ) ;
} else {
unlink _node ( context , oldpath , callback ) ;
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function check _node _type ( error , node ) {
if ( error ) {
=== === =
// Update the parent nodes data
function update _parent _node _data ( error ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
callback ( error ) ;
2018-06-28 17:35:20 +00:00
} else if ( node . mode === 'DIRECTORY' ) {
find _node ( context , oldParentPath , read _parent _directory _data ) ;
2014-05-27 18:44:30 +00:00
} else {
2018-06-28 17:35:20 +00:00
<< << << < HEAD
link _node ( context , oldpath , newpath , unlink _old _file ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-06-25 12:27:14 +00:00
if ( typeof atime !== 'number' || typeof mtime !== 'number' ) {
2014-05-27 18:44:30 +00:00
callback ( new Errors . EINVAL ( 'atime and mtime must be a number' ) ) ;
}
else if ( atime < 0 || mtime < 0 ) {
callback ( new Errors . EINVAL ( 'atime and mtime must be positive integers' ) ) ;
}
else {
2014-10-24 11:56:16 +00:00
ofd . getNode ( context , update _times ) ;
2014-05-27 18:44:30 +00:00
}
}
function setxattr _file ( context , path , name , value , flag , callback ) {
path = normalize ( path ) ;
2014-10-24 11:56:16 +00:00
function setxattr ( error , node ) {
if ( error ) {
return callback ( error ) ;
}
set _extended _attribute ( context , path , node , name , value , flag , callback ) ;
}
2018-06-25 12:27:14 +00:00
if ( typeof name !== 'string' ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EINVAL ( 'attribute name must be a string' , path ) ) ;
2014-05-27 18:44:30 +00:00
}
else if ( ! name ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' , path ) ) ;
2014-05-27 18:44:30 +00:00
}
else if ( flag !== null &&
flag !== XATTR _CREATE && flag !== XATTR _REPLACE ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EINVAL ( 'invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE' , path ) ) ;
2014-05-27 18:44:30 +00:00
}
else {
2014-10-24 11:56:16 +00:00
find _node ( context , path , setxattr ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
find _node ( context , oldpath , check _node _type ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function symlink ( fs , context , srcpath , dstpath , type , callback ) {
// NOTE: we support passing the `type` arg, but ignore it.
callback = arguments [ arguments . length - 1 ] ;
if ( ! pathCheck ( srcpath , callback ) ) return ;
if ( ! pathCheck ( dstpath , callback ) ) return ;
make _symbolic _link ( context , srcpath , dstpath , callback ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
function readlink ( fs , context , path , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
read _link ( context , path , callback ) ;
}
=== === =
parentNodeData [ name ] = new DirectoryEntry ( node . id , mode ) ;
context . putObject ( parentNode . data , parentNodeData , update _time ) ;
2014-10-24 11:56:16 +00:00
}
}
2018-06-28 17:35:20 +00:00
// Find the parent node
find _node ( context , parentPath , create _node _in _parent ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
/ * *
* find _node
* /
// in: file or directory path
// out: node structure, or error
function find _node ( context , path , callback ) {
2014-05-27 18:44:30 +00:00
path = normalize ( path ) ;
2018-06-28 17:35:20 +00:00
if ( ! path ) {
return callback ( new Errors . ENOENT ( 'path is an empty string' ) ) ;
}
var name = basename ( path ) ;
var parentPath = dirname ( path ) ;
var followedCount = 0 ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function read _root _directory _node ( error , superNode ) {
if ( error ) {
callback ( error ) ;
} else if ( ! superNode || superNode . mode !== MODE _META || ! superNode . rnode ) {
callback ( new Errors . EFILESYSTEMERROR ( ) ) ;
} else {
context . getObject ( superNode . rnode , check _root _directory _node ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-10-24 11:56:16 +00:00
2018-06-28 17:35:20 +00:00
function check _root _directory _node ( error , rootDirectoryNode ) {
if ( error ) {
callback ( error ) ;
} else if ( ! rootDirectoryNode ) {
callback ( new Errors . ENOENT ( ) ) ;
} else {
callback ( null , rootDirectoryNode ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
// in: parent directory node
// out: parent directory data
function read _parent _directory _data ( error , parentDirectoryNode ) {
if ( error ) {
callback ( error ) ;
} else if ( parentDirectoryNode . mode !== MODE _DIRECTORY || ! parentDirectoryNode . data ) {
callback ( new Errors . ENOTDIR ( 'a component of the path prefix is not a directory' , path ) ) ;
} else {
context . getObject ( parentDirectoryNode . data , get _node _from _parent _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-06-25 12:27:14 +00:00
if ( typeof name !== 'string' ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EINVAL ( 'attribute name must be a string' , path ) ) ;
2014-05-27 18:44:30 +00:00
}
else if ( ! name ) {
2014-08-20 18:48:40 +00:00
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' , path ) ) ;
2014-05-27 18:44:30 +00:00
}
else {
find _node ( context , path , get _xattr ) ;
2018-06-28 17:35:20 +00:00
=== === =
// in: parent directory data
// out: searched node
function get _node _from _parent _directory _data ( error , parentDirectoryData ) {
if ( error ) {
callback ( error ) ;
} else {
if ( ! _ ( parentDirectoryData ) . has ( name ) ) {
callback ( new Errors . ENOENT ( null , path ) ) ;
} else {
var nodeId = parentDirectoryData [ name ] . id ;
context . getObject ( nodeId , is _symbolic _link ) ;
}
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
function truncate ( fs , context , path , length , callback ) {
// NOTE: length is optional
callback = arguments [ arguments . length - 1 ] ;
length = length || 0 ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( ! pathCheck ( path , callback ) ) return ;
truncate _file ( context , path , length , callback ) ;
}
=== === =
function is _symbolic _link ( error , node ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
2018-06-28 17:35:20 +00:00
callback ( error ) ;
} else {
if ( node . mode == MODE _SYMBOLIC _LINK ) {
followedCount ++ ;
if ( followedCount > SYMLOOP _MAX ) {
callback ( new Errors . ELOOP ( null , path ) ) ;
} else {
follow _symbolic _link ( node . data ) ;
}
} else {
callback ( null , node ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-10-24 11:56:16 +00:00
2018-06-28 17:35:20 +00:00
function follow _symbolic _link ( data ) {
data = normalize ( data ) ;
parentPath = dirname ( data ) ;
name = basename ( data ) ;
if ( ROOT _DIRECTORY _NAME == name ) {
context . getObject ( SUPER _NODE _ID , read _root _directory _node ) ;
} else {
find _node ( context , parentPath , read _parent _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-06-25 12:27:14 +00:00
if ( typeof name !== 'string' ) {
2014-05-27 18:44:30 +00:00
callback ( new Errors . EINVAL ( ) ) ;
}
else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' ) ) ;
}
else {
2014-10-24 11:56:16 +00:00
ofd . getNode ( context , get _xattr ) ;
2018-06-28 17:35:20 +00:00
=== === =
if ( ROOT _DIRECTORY _NAME == name ) {
context . getObject ( SUPER _NODE _ID , read _root _directory _node ) ;
} else {
<< << << < HEAD
ftruncate _file ( context , ofd , length , callback ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
module . exports = {
ensureRootDirectory : ensure _root _directory ,
open : open ,
close : close ,
mknod : mknod ,
mkdir : mkdir ,
rmdir : rmdir ,
unlink : unlink ,
stat : stat ,
fstat : fstat ,
link : link ,
read : read ,
readFile : readFile ,
write : write ,
writeFile : writeFile ,
appendFile : appendFile ,
exists : exists ,
getxattr : getxattr ,
fgetxattr : fgetxattr ,
setxattr : setxattr ,
fsetxattr : fsetxattr ,
removexattr : removexattr ,
fremovexattr : fremovexattr ,
lseek : lseek ,
readdir : readdir ,
utimes : utimes ,
futimes : futimes ,
rename : rename ,
symlink : symlink ,
readlink : readlink ,
lstat : lstat ,
truncate : truncate ,
ftruncate : ftruncate
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
} , { "../../lib/nodash.js" : 4 , "../buffer.js" : 14 , "../constants.js" : 15 , "../directory-entry.js" : 16 , "../encoding.js" : 17 , "../errors.js" : 18 , "../node.js" : 23 , "../open-file-description.js" : 24 , "../path.js" : 25 , "../stats.js" : 33 , "../super-node.js" : 34 } ] , 20 : [ function ( require , module , exports ) {
var _ = require ( '../../lib/nodash.js' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var isNullPath = require ( '../path.js' ) . isNull ;
var nop = require ( '../shared.js' ) . nop ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var Constants = require ( '../constants.js' ) ;
var FILE _SYSTEM _NAME = Constants . FILE _SYSTEM _NAME ;
var FS _FORMAT = Constants . FS _FORMAT ;
var FS _READY = Constants . FS _READY ;
var FS _PENDING = Constants . FS _PENDING ;
var FS _ERROR = Constants . FS _ERROR ;
var FS _NODUPEIDCHECK = Constants . FS _NODUPEIDCHECK ;
2014-10-24 11:56:16 +00:00
2018-06-28 17:35:20 +00:00
var providers = require ( '../providers/index.js' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var Shell = require ( '../shell/shell.js' ) ;
var Intercom = require ( '../../lib/intercom.js' ) ;
var FSWatcher = require ( '../fs-watcher.js' ) ;
var Errors = require ( '../errors.js' ) ;
var defaultGuidFn = require ( '../shared.js' ) . guid ;
=== === =
find _node ( context , parentPath , read _parent _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
/ * *
* set extended attribute ( refactor )
* /
function set _extended _attribute ( context , path _or _fd , name , value , flag , callback ) {
var path ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function set _xattr ( error , node ) {
var xattr = node ? node . xattrs [ name ] : null ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-10-24 11:56:16 +00:00
2014-05-27 18:44:30 +00:00
function update _time ( error ) {
2018-06-28 17:35:20 +00:00
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
update _node _times ( context , path , node , { ctime : Date . now ( ) } , callback ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
// The core fs operations live on impl
var impl = require ( './implementation.js' ) ;
=== === =
if ( error ) {
callback ( error ) ;
} else if ( flag === XATTR _CREATE && node . xattrs . hasOwnProperty ( name ) ) {
callback ( new Errors . EEXIST ( 'attribute already exists' , path _or _fd ) ) ;
} else if ( flag === XATTR _REPLACE && ! node . xattrs . hasOwnProperty ( name ) ) {
callback ( new Errors . ENOATTR ( null , path _or _fd ) ) ;
} else {
node . xattrs [ name ] = value ;
2014-08-17 05:56:03 +00:00
context . putObject ( node . id , node , update _time ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-06-25 12:27:14 +00:00
if ( typeof name !== 'string' ) {
2014-05-27 18:44:30 +00:00
callback ( new Errors . EINVAL ( 'attribute name must be a string' ) ) ;
}
else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' ) ) ;
}
else {
2014-10-24 11:56:16 +00:00
ofd . getNode ( context , remove _xattr ) ;
2014-05-27 18:44:30 +00:00
}
}
function validate _flags ( flags ) {
if ( ! _ ( O _FLAGS ) . has ( flags ) ) {
return null ;
}
return O _FLAGS [ flags ] ;
}
function validate _file _options ( options , enc , fileMode ) {
if ( ! options ) {
options = { encoding : enc , flag : fileMode } ;
} else if ( typeof options === "function" ) {
options = { encoding : enc , flag : fileMode } ;
} else if ( typeof options === "string" ) {
options = { encoding : options , flag : fileMode } ;
2018-06-28 17:35:20 +00:00
=== === =
if ( typeof path _or _fd == 'string' ) {
path = path _or _fd ;
find _node ( context , path _or _fd , set _xattr ) ;
} else if ( ( typeof path _or _fd === 'undefined' ? 'undefined' : _typeof ( path _or _fd ) ) == 'object' && typeof path _or _fd . id == 'string' ) {
path = path _or _fd . path ;
context . getObject ( path _or _fd . id , set _xattr ) ;
} else {
callback ( new Errors . EINVAL ( 'path or file descriptor of wrong type' , path _or _fd ) ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
function pathCheck ( path , allowRelative , callback ) {
2014-05-27 18:44:30 +00:00
var err ;
2014-08-22 16:35:13 +00:00
2018-05-29 18:03:59 +00:00
if ( typeof allowRelative === 'function' ) {
callback = allowRelative ;
allowRelative = false ;
}
2014-08-22 16:35:13 +00:00
if ( ! path ) {
err = new Errors . EINVAL ( 'Path must be a string' , path ) ;
} else if ( isNullPath ( path ) ) {
2014-08-20 18:48:40 +00:00
err = new Errors . EINVAL ( 'Path must be a string without null bytes.' , path ) ;
2018-05-29 18:03:59 +00:00
} else if ( ! allowRelative && ! isAbsolutePath ( path ) ) {
2014-08-22 16:35:13 +00:00
err = new Errors . EINVAL ( 'Path must be absolute.' , path ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
// Default callback that logs an error if passed in
function defaultCallback ( err ) {
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
if ( err ) {
2018-06-28 17:35:20 +00:00
console . error ( 'Filer error: ' , err ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
/ * *
* ensure _root _directory . Creates a root node if necessary .
*
* Note : this should only be invoked when formatting a new file system .
* Multiple invocations of this by separate instances will still result
* in only a single super node .
* /
<< << << < HEAD
function FileSystem ( options , callback ) {
options = options || { } ;
callback = callback || defaultCallback ;
=== === =
function ensure _root _directory ( context , callback ) {
var superNode ;
var directoryNode ;
var directoryData ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function open ( fs , context , path , flags , mode , callback ) {
2018-05-29 18:03:59 +00:00
/ * *
* NOTE : we support the same signature as node with a ` mode ` arg ,
* but ignore it . We need to add it . Here is what node . js does :
* function open ( path , flags , mode , callback ) {
* path = getPathFromURL ( path ) ;
* validatePath ( path ) ;
* const flagsNumber = stringToFlags ( flags ) ;
* if ( arguments . length < 4 ) {
* callback = makeCallback ( mode ) ;
* mode = 0o666 ;
* } else {
* mode = validateAndMaskMode ( mode , 'mode' , 0o666 ) ;
* callback = makeCallback ( callback ) ;
* }
* /
2014-05-27 18:44:30 +00:00
callback = arguments [ arguments . length - 1 ] ;
if ( ! pathCheck ( path , callback ) ) return ;
2018-06-28 17:35:20 +00:00
=== === =
function ensure _super _node ( error , existingNode ) {
if ( ! error && existingNode ) {
// Another instance has beat us and already created the super node.
callback ( ) ;
} else if ( error && ! ( error instanceof Errors . ENOENT ) ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
SuperNode . create ( { guid : context . guid } , function ( error , result ) {
if ( error ) {
callback ( error ) ;
return ;
}
superNode = result ;
context . putObject ( superNode . id , superNode , write _directory _node ) ;
} ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function write _directory _node ( error ) {
if ( error ) {
callback ( error ) ;
} else {
Node . create ( { guid : context . guid , id : superNode . rnode , mode : MODE _DIRECTORY } , function ( error , result ) {
if ( error ) {
callback ( error ) ;
return ;
}
directoryNode = result ;
directoryNode . nlinks += 1 ;
context . putObject ( directoryNode . id , directoryNode , write _directory _data ) ;
} ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function write _directory _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData = { } ;
context . putObject ( directoryNode . data , directoryData , callback ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
function mknod ( fs , context , path , type , callback ) {
2014-05-27 18:44:30 +00:00
if ( ! pathCheck ( path , callback ) ) return ;
2018-05-29 18:03:59 +00:00
make _node ( context , path , type , callback ) ;
2014-05-27 18:44:30 +00:00
}
function mkdir ( fs , context , path , mode , callback ) {
2018-05-29 18:03:59 +00:00
if ( arguments . length < 5 ) {
callback = mode ;
mode = FULL _READ _WRITE _EXEC _PERMISSIONS ;
} else {
mode = validateAndMaskMode ( mode , FULL _READ _WRITE _EXEC _PERMISSIONS , callback ) ;
if ( ! mode ) return ;
}
2014-05-27 18:44:30 +00:00
if ( ! pathCheck ( path , callback ) ) return ;
2014-10-24 11:56:16 +00:00
make _directory ( context , path , callback ) ;
2018-06-28 17:35:20 +00:00
=== === =
<< << << < HEAD
// Expose Shell constructor
this . Shell = Shell . bind ( undefined , this ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Safely expose the list of open files and file
// descriptor management functions
var openFiles = { } ;
var nextDescriptor = FIRST _DESCRIPTOR ;
Object . defineProperty ( this , "openFiles" , {
get : function ( ) { return openFiles ; }
} ) ;
this . allocDescriptor = function ( openFileDescription ) {
var fd = nextDescriptor ++ ;
openFiles [ fd ] = openFileDescription ;
return fd ;
} ;
this . releaseDescriptor = function ( fd ) {
delete openFiles [ fd ] ;
} ;
=== === =
context . getObject ( SUPER _NODE _ID , ensure _super _node ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
/ * *
* make _directory
* /
function make _directory ( context , path , callback ) {
path = normalize ( path ) ;
var name = basename ( path ) ;
var parentPath = dirname ( path ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var directoryNode ;
var directoryData ;
var parentDirectoryNode ;
var parentDirectoryData ;
function check _if _directory _exists ( error , result ) {
if ( ! error && result ) {
callback ( new Errors . EEXIST ( null , path ) ) ;
} else if ( error && ! ( error instanceof Errors . ENOENT ) ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
var stats = new Stats ( path , result , fs . name ) ;
2014-05-27 18:44:30 +00:00
callback ( null , stats ) ;
2018-06-28 17:35:20 +00:00
=== === =
find _node ( context , parentPath , read _parent _directory _data ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function read _parent _directory _data ( error , result ) {
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
var stats = new Stats ( ofd . path , result , fs . name ) ;
2014-05-27 18:44:30 +00:00
callback ( null , stats ) ;
2018-06-28 17:35:20 +00:00
=== === =
parentDirectoryNode = result ;
context . getObject ( parentDirectoryNode . data , write _directory _node ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function write _directory _node ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
parentDirectoryData = result ;
Node . create ( { guid : context . guid , mode : MODE _DIRECTORY } , function ( error , result ) {
if ( error ) {
callback ( error ) ;
return ;
}
directoryNode = result ;
directoryNode . nlinks += 1 ;
context . putObject ( directoryNode . id , directoryNode , write _directory _data ) ;
} ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function write _directory _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData = { } ;
context . putObject ( directoryNode . data , directoryData , update _parent _directory _data ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
} else {
var now = Date . now ( ) ;
update _node _times ( context , parentPath , parentDirectoryNode , { mtime : now , ctime : now } , callback ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function update _parent _directory _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
parentDirectoryData [ name ] = new DirectoryEntry ( directoryNode . id , MODE _DIRECTORY ) ;
context . putObject ( parentDirectoryNode . data , parentDirectoryData , update _time ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
find _node ( context , path , check _if _directory _exists ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
/ * *
* remove _directory
* /
function remove _directory ( context , path , callback ) {
path = normalize ( path ) ;
var name = basename ( path ) ;
var parentPath = dirname ( path ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var directoryNode ;
var directoryData ;
var parentDirectoryNode ;
var parentDirectoryData ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function read _parent _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
parentDirectoryNode = result ;
context . getObject ( parentDirectoryNode . data , check _if _node _exists ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function check _if _node _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else if ( ROOT _DIRECTORY _NAME == name ) {
callback ( new Errors . EBUSY ( null , path ) ) ;
} else if ( ! _ ( result ) . has ( name ) ) {
callback ( new Errors . ENOENT ( null , path ) ) ;
} else {
parentDirectoryData = result ;
directoryNode = parentDirectoryData [ name ] . id ;
context . getObject ( directoryNode , check _if _node _is _directory ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function check _if _node _is _directory ( error , result ) {
if ( error ) {
callback ( error ) ;
} else if ( result . mode != MODE _DIRECTORY ) {
callback ( new Errors . ENOTDIR ( null , path ) ) ;
} else {
directoryNode = result ;
context . getObject ( directoryNode . data , check _if _directory _is _empty ) ;
2014-08-18 15:31:56 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-08-18 15:31:56 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-08-18 15:31:56 +00:00
fstat _file ( context , ofd , function ( err , fstatResult ) {
if ( err ) {
cleanup ( ) ;
return callback ( err ) ;
2014-05-27 18:44:30 +00:00
}
2018-05-29 18:03:59 +00:00
var stats = new Stats ( ofd . path , fstatResult , fs . name ) ;
2014-08-18 15:31:56 +00:00
if ( stats . isDirectory ( ) ) {
cleanup ( ) ;
2014-08-20 18:48:40 +00:00
return callback ( new Errors . EISDIR ( 'illegal operation on directory' , path ) ) ;
2018-06-28 17:35:20 +00:00
=== === =
function check _if _directory _is _empty ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData = result ;
if ( _ ( directoryData ) . size ( ) > 0 ) {
callback ( new Errors . ENOTEMPTY ( null , path ) ) ;
} else {
remove _directory _entry _from _parent _directory _node ( ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-08-18 15:31:56 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
} else {
var now = Date . now ( ) ;
update _node _times ( context , parentPath , parentDirectoryNode , { mtime : now , ctime : now } , remove _directory _node ) ;
}
<< << << < HEAD
} ;
} ) ;
module . exports = FileSystem ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
} , { "../../lib/intercom.js" : 3 , "../../lib/nodash.js" : 4 , "../constants.js" : 15 , "../errors.js" : 18 , "../fs-watcher.js" : 21 , "../path.js" : 25 , "../providers/index.js" : 26 , "../shared.js" : 30 , "../shell/shell.js" : 32 , "./implementation.js" : 19 } ] , 21 : [ function ( require , module , exports ) {
var EventEmitter = require ( '../lib/eventemitter.js' ) ;
var Path = require ( './path.js' ) ;
var Intercom = require ( '../lib/intercom.js' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
/ * *
* FSWatcher based on node . js ' FSWatcher
* see https : //github.com/joyent/node/blob/master/lib/fs.js
* /
function FSWatcher ( ) {
EventEmitter . call ( this ) ;
var self = this ;
var recursive = false ;
var recursivePathPrefix ;
var filename ;
=== === =
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function remove _directory _entry _from _parent _directory _node ( ) {
delete parentDirectoryData [ name ] ;
context . putObject ( parentDirectoryNode . data , parentDirectoryData , update _time ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function remove _directory _node ( error ) {
if ( error ) {
callback ( error ) ;
} else {
context . delete ( directoryNode . id , remove _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function remove _directory _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
context . delete ( directoryNode . data , callback ) ;
}
}
2014-08-18 15:31:56 +00:00
2018-06-28 17:35:20 +00:00
find _node ( context , parentPath , read _parent _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function open _file ( context , path , flags , callback ) {
path = normalize ( path ) ;
var name = basename ( path ) ;
var parentPath = dirname ( path ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var directoryNode ;
var directoryData ;
var directoryEntry ;
var fileNode ;
var fileData ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var followedCount = 0 ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
} , { "../lib/eventemitter.js" : 2 , "../lib/intercom.js" : 3 , "./path.js" : 25 } ] , 22 : [ function ( require , module , exports ) {
module . exports = {
FileSystem : require ( './filesystem/interface.js' ) ,
Buffer : require ( './buffer.js' ) ,
Path : require ( './path.js' ) ,
Errors : require ( './errors.js' ) ,
Shell : require ( './shell/shell.js' )
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
} , { "./buffer.js" : 14 , "./errors.js" : 18 , "./filesystem/interface.js" : 20 , "./path.js" : 25 , "./shell/shell.js" : 32 } ] , 23 : [ function ( require , module , exports ) {
var MODE _FILE = require ( './constants.js' ) . MODE _FILE ;
=== === =
if ( ROOT _DIRECTORY _NAME == name ) {
if ( _ ( flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EISDIR ( 'the named file is a directory and O_WRITE is set' , path ) ) ;
} else {
find _node ( context , path , set _file _node ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} else {
find _node ( context , parentPath , read _directory _data ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function read _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
} else if ( result . mode !== MODE _DIRECTORY ) {
callback ( new Errors . ENOENT ( null , path ) ) ;
} else {
directoryNode = result ;
context . getObject ( directoryNode . data , check _if _file _exists ) ;
}
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-08-18 15:31:56 +00:00
2018-06-28 17:35:20 +00:00
function check _if _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData = result ;
if ( _ ( directoryData ) . has ( name ) ) {
if ( _ ( flags ) . contains ( O _EXCLUSIVE ) ) {
callback ( new Errors . ENOENT ( 'O_CREATE and O_EXCLUSIVE are set, and the named file exists' , path ) ) ;
} else {
directoryEntry = directoryData [ name ] ;
if ( directoryEntry . type == MODE _DIRECTORY && _ ( flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EISDIR ( 'the named file is a directory and O_WRITE is set' , path ) ) ;
} else {
context . getObject ( directoryEntry . id , check _if _symbolic _link ) ;
}
}
} else {
if ( ! _ ( flags ) . contains ( O _CREATE ) ) {
callback ( new Errors . ENOENT ( 'O_CREATE is not set and the named file does not exist' , path ) ) ;
} else {
write _file _node ( ) ;
}
2014-08-18 15:31:56 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
stat ( fs , context , path , cb ) ;
}
2018-05-29 18:03:59 +00:00
// Based on https://github.com/nodejs/node/blob/c700cc42da9cf73af9fec2098520a6c0a631d901/lib/internal/validators.js#L21
var octalReg = /^[0-7]+$/ ;
var modeDesc = 'must be a 32-bit unsigned integer or an octal string' ;
function isUint32 ( value ) {
return value === ( value >>> 0 ) ;
}
// Validator for mode_t (the S_* constants). Valid numbers or octal strings
// will be masked with 0o777 to be consistent with the behavior in POSIX APIs.
function validateAndMaskMode ( value , def , callback ) {
if ( typeof def === 'function' ) {
callback = def ;
def = undefined ;
}
if ( isUint32 ( value ) ) {
return value & FULL _READ _WRITE _EXEC _PERMISSIONS ;
}
if ( typeof value === 'number' ) {
if ( ! Number . isInteger ( value ) ) {
callback ( new Errors . EINVAL ( 'mode not a valid an integer value' , value ) ) ;
return false ;
} else {
// 2 ** 32 === 4294967296
callback ( new Errors . EINVAL ( 'mode not a valid an integer value' , value ) ) ;
return false ;
}
}
if ( typeof value === 'string' ) {
if ( ! octalReg . test ( value ) ) {
callback ( new Errors . EINVAL ( 'mode not a valid octal string' , value ) ) ;
return false ;
}
var parsed = parseInt ( value , 8 ) ;
return parsed & FULL _READ _WRITE _EXEC _PERMISSIONS ;
}
2018-06-25 12:27:14 +00:00
// TODO(BridgeAR): Only return `def` in case `value === null`
2018-05-29 18:03:59 +00:00
if ( def !== undefined ) {
return def ;
}
callback ( new Errors . EINVAL ( 'mode not valid' , value ) ) ;
return false ;
}
function chmod _file ( context , path , mode , callback ) {
path = normalize ( path ) ;
function update _mode ( error , node ) {
if ( error ) {
callback ( error ) ;
} else {
Node . setMode ( mode , node ) ;
update _node _times ( context , path , node , { mtime : Date . now ( ) } , callback ) ;
}
}
2018-06-25 12:27:14 +00:00
if ( typeof mode !== 'number' ) {
2018-05-29 18:03:59 +00:00
callback ( new Errors . EINVAL ( 'mode must be number' , path ) ) ;
}
else {
find _node ( context , path , update _mode ) ;
}
}
function fchmod _file ( context , ofd , mode , callback ) {
function update _mode ( error , node ) {
if ( error ) {
callback ( error ) ;
} else {
node . mode = mode ;
update _node _times ( context , ofd . path , node , { mtime : Date . now ( ) } , callback ) ;
}
}
2018-06-25 12:27:14 +00:00
if ( typeof mode !== 'number' ) {
2018-05-29 18:03:59 +00:00
callback ( new Errors . EINVAL ( 'mode must be a number' ) ) ;
}
else {
ofd . getNode ( context , update _mode ) ;
}
}
function chown _file ( context , path , uid , gid , callback ) {
path = normalize ( path ) ;
function update _owner ( error , node ) {
if ( error ) {
callback ( error ) ;
} else {
node . uid = uid ;
node . gid = gid ;
update _node _times ( context , path , node , { mtime : Date . now ( ) } , callback ) ;
}
}
find _node ( context , path , update _owner ) ;
}
function fchown _file ( context , ofd , uid , gid , callback ) {
function update _owner ( error , node ) {
if ( error ) {
callback ( error ) ;
} else {
node . uid = uid ;
node . gid = gid ;
update _node _times ( context , ofd . path , node , { mtime : Date . now ( ) } , callback ) ;
}
}
ofd . getNode ( context , update _owner ) ;
}
2014-05-27 18:44:30 +00:00
function getxattr ( fs , context , path , name , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
2014-10-24 11:56:16 +00:00
getxattr _file ( context , path , name , callback ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
=== === =
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function check _if _symbolic _link ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
var node = result ;
if ( node . mode == MODE _SYMBOLIC _LINK ) {
followedCount ++ ;
if ( followedCount > SYMLOOP _MAX ) {
callback ( new Errors . ELOOP ( null , path ) ) ;
} else {
follow _symbolic _link ( node . data ) ;
}
} else {
set _file _node ( undefined , node ) ;
}
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function follow _symbolic _link ( data ) {
data = normalize ( data ) ;
parentPath = dirname ( data ) ;
name = basename ( data ) ;
if ( ROOT _DIRECTORY _NAME == name ) {
if ( _ ( flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EISDIR ( 'the named file is a directory and O_WRITE is set' , path ) ) ;
} else {
find _node ( context , path , set _file _node ) ;
}
}
find _node ( context , parentPath , read _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-25 12:27:14 +00:00
2018-06-28 17:35:20 +00:00
function set _file _node ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
fileNode = result ;
callback ( null , fileNode ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function write _file _node ( ) {
Node . create ( { guid : context . guid , mode : MODE _FILE } , function ( error , result ) {
if ( error ) {
callback ( error ) ;
return ;
}
fileNode = result ;
fileNode . nlinks += 1 ;
context . putObject ( fileNode . id , fileNode , write _file _data ) ;
} ) ;
<< << << < HEAD
} ) ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
module . exports = Node ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
} , { "./constants.js" : 15 } ] , 24 : [ function ( require , module , exports ) {
var Errors = require ( './errors.js' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function OpenFileDescription ( path , id , flags , position ) {
this . path = path ;
this . id = id ;
this . flags = flags ;
this . position = position ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
// Tries to find the node associated with an ofd's `id`.
// If not found, an error is returned on the callback.
OpenFileDescription . prototype . getNode = function ( context , callback ) {
var id = this . id ;
var path = this . path ;
function check _if _node _exists ( error , node ) {
if ( error ) {
return callback ( error ) ;
}
if ( ! node ) {
return callback ( new Errors . EBADF ( 'file descriptor refers to unknown node' , path ) ) ;
}
callback ( null , node ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
context . getObject ( id , check _if _node _exists ) ;
} ;
module . exports = OpenFileDescription ;
} , { "./errors.js" : 18 } ] , 25 : [ function ( require , module , exports ) {
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
=== === =
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function write _file _data ( error ) {
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
fileData = new Buffer ( 0 ) ;
fileData . fill ( 0 ) ;
context . putBuffer ( fileNode . data , fileData , update _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
2014-05-27 18:44:30 +00:00
} else {
2018-06-28 17:35:20 +00:00
var now = Date . now ( ) ;
update _node _times ( context , parentPath , directoryNode , { mtime : now , ctime : now } , handle _update _result ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function update _directory _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData [ name ] = new DirectoryEntry ( fileNode . id , MODE _FILE ) ;
context . putObject ( directoryNode . data , directoryData , update _time ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
}
2018-05-29 18:03:59 +00:00
function chmod ( fs , context , path , mode , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
mode = validateAndMaskMode ( mode , 'mode' ) ;
if ( ! mode ) return ;
chmod _file ( context , path , mode , callback ) ;
}
function fchmod ( fs , context , fd , mode , callback ) {
mode = validateAndMaskMode ( mode , 'mode' ) ;
if ( ! mode ) return ;
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else if ( ! _ ( ofd . flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit writing' ) ) ;
} else {
fchmod _file ( context , ofd , mode , callback ) ;
}
}
function chown ( fs , context , path , uid , gid , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
if ( ! isUint32 ( uid ) ) {
return callback ( new Errors . EINVAL ( 'uid must be a valid integer' , uid ) ) ;
}
if ( ! isUint32 ( gid ) ) {
return callback ( new Errors . EINVAL ( 'gid must be a valid integer' , gid ) ) ;
}
chown _file ( context , path , uid , gid , callback ) ;
}
function fchown ( fs , context , fd , uid , gid , callback ) {
if ( ! isUint32 ( uid ) ) {
return callback ( new Errors . EINVAL ( 'uid must be a valid integer' , uid ) ) ;
}
if ( ! isUint32 ( gid ) ) {
return callback ( new Errors . EINVAL ( 'gid must be a valid integer' , gid ) ) ;
}
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else if ( ! _ ( ofd . flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit writing' ) ) ;
} else {
fchown _file ( context , ofd , uid , gid , callback ) ;
}
}
2014-05-27 18:44:30 +00:00
function rename ( fs , context , oldpath , newpath , callback ) {
if ( ! pathCheck ( oldpath , callback ) ) return ;
if ( ! pathCheck ( newpath , callback ) ) return ;
2015-05-12 19:44:26 +00:00
oldpath = normalize ( oldpath ) ;
newpath = normalize ( newpath ) ;
2014-12-17 07:35:01 +00:00
var oldParentPath = Path . dirname ( oldpath ) ;
var newParentPath = Path . dirname ( oldpath ) ;
var oldName = Path . basename ( oldpath ) ;
var newName = Path . basename ( newpath ) ;
var oldParentDirectory , oldParentData ;
var newParentDirectory , newParentData ;
2018-05-29 18:03:59 +00:00
var ctime = Date . now ( ) ;
var fileNode ;
2014-12-17 07:35:01 +00:00
2018-05-29 18:03:59 +00:00
function update _times ( error , result ) {
2014-12-17 07:35:01 +00:00
if ( error ) {
callback ( error ) ;
} else {
2018-05-29 18:03:59 +00:00
fileNode = result ;
update _node _times ( context , newpath , fileNode , { ctime : ctime } , callback ) ;
2018-06-28 17:35:20 +00:00
=== === =
function handle _update _result ( error ) {
if ( error ) {
callback ( error ) ;
} else {
callback ( null , fileNode ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-12-17 07:35:01 +00:00
}
}
2018-06-28 17:35:20 +00:00
}
2014-12-17 07:35:01 +00:00
2018-06-28 17:35:20 +00:00
function replace _data ( context , ofd , buffer , offset , length , callback ) {
var fileNode ;
<< << << < HEAD
for ( var i = arguments . length - 1 ; i >= - 1 && ! resolvedAbsolute ; i -- ) {
// XXXfiler: we don't have process.cwd() so we use '/' as a fallback
var path = ( i >= 0 ) ? arguments [ i ] : '/' ;
=== === =
function return _nbytes ( error ) {
if ( error ) {
2014-12-17 07:35:01 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
callback ( null , length ) ;
2014-12-17 07:35:01 +00:00
}
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-12-17 07:35:01 +00:00
2018-06-28 17:35:20 +00:00
function update _time ( error ) {
if ( error ) {
2014-12-17 07:35:01 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
var now = Date . now ( ) ;
update _node _times ( context , ofd . path , fileNode , { mtime : now , ctime : now } , return _nbytes ) ;
2014-12-17 07:35:01 +00:00
}
}
2018-06-28 17:35:20 +00:00
function update _file _node ( error ) {
if ( error ) {
2014-12-17 07:35:01 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
context . putObject ( fileNode . id , fileNode , update _time ) ;
2014-12-17 07:35:01 +00:00
}
}
2018-06-28 17:35:20 +00:00
function write _file _data ( error , result ) {
if ( error ) {
2014-12-17 07:35:01 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
fileNode = result ;
var newData = new Buffer ( length ) ;
newData . fill ( 0 ) ;
buffer . copy ( newData , 0 , offset , offset + length ) ;
ofd . position = length ;
fileNode . size = length ;
fileNode . version += 1 ;
context . putBuffer ( fileNode . data , newData , update _file _node ) ;
2014-12-17 07:35:01 +00:00
}
}
2018-06-28 17:35:20 +00:00
context . getObject ( ofd . id , write _file _data ) ;
}
<< << << < HEAD
// path.relative(from, to)
function relative ( from , to ) {
from = resolve ( from ) . substr ( 1 ) ;
to = resolve ( to ) . substr ( 1 ) ;
=== === =
function write _data ( context , ofd , buffer , offset , length , position , callback ) {
var fileNode ;
var fileData ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
function return _nbytes ( error ) {
if ( error ) {
2014-12-17 07:35:01 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
callback ( null , length ) ;
2014-12-17 07:35:01 +00:00
}
}
2018-06-28 17:35:20 +00:00
function update _time ( error ) {
if ( error ) {
2014-12-17 07:35:01 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
var now = Date . now ( ) ;
update _node _times ( context , ofd . path , fileNode , { mtime : now , ctime : now } , return _nbytes ) ;
2014-12-17 07:35:01 +00:00
}
}
2018-06-28 17:35:20 +00:00
function update _file _node ( error ) {
if ( error ) {
2014-12-17 07:35:01 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
context . putObject ( fileNode . id , fileNode , update _time ) ;
2014-12-17 07:35:01 +00:00
}
}
2018-06-28 17:35:20 +00:00
function update _file _data ( error , result ) {
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
fileData = result ;
if ( ! fileData ) {
return callback ( new Errors . EIO ( 'Expected Buffer' ) ) ;
}
var _position = ! ( undefined === position || null === position ) ? position : ofd . position ;
var newSize = Math . max ( fileData . length , _position + length ) ;
var newData = new Buffer ( newSize ) ;
newData . fill ( 0 ) ;
if ( fileData ) {
fileData . copy ( newData ) ;
}
buffer . copy ( newData , _position , offset , offset + length ) ;
if ( undefined === position ) {
ofd . position += length ;
}
fileNode . size = newSize ;
fileNode . version += 1 ;
context . putBuffer ( fileNode . data , newData , update _file _node ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function read _file _data ( error , result ) {
if ( error ) {
2014-12-17 07:35:01 +00:00
callback ( error ) ;
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
} else if ( node . type === NODE _TYPE _DIRECTORY ) {
2014-12-17 07:35:01 +00:00
find _node ( context , oldParentPath , read _parent _directory _data ) ;
2018-06-28 17:35:20 +00:00
=== === =
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-12-17 07:35:01 +00:00
} else {
2018-06-28 17:35:20 +00:00
fileNode = result ;
context . getBuffer ( fileNode . data , update _file _data ) ;
2014-12-17 07:35:01 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-12-17 07:35:01 +00:00
find _node ( context , oldpath , check _node _type ) ;
2014-05-27 18:44:30 +00:00
}
function symlink ( fs , context , srcpath , dstpath , type , callback ) {
// NOTE: we support passing the `type` arg, but ignore it.
callback = arguments [ arguments . length - 1 ] ;
2018-05-29 18:03:59 +00:00
// Special Case: allow srcpath to be relative, which we normally don't permit.
// If the srcpath is relative, we assume it's relative to the dirpath of
// dstpath.
if ( ! pathCheck ( srcpath , true , callback ) ) return ;
2014-05-27 18:44:30 +00:00
if ( ! pathCheck ( dstpath , callback ) ) return ;
2018-05-29 18:03:59 +00:00
2014-10-24 11:56:16 +00:00
make _symbolic _link ( context , srcpath , dstpath , callback ) ;
2018-06-28 17:35:20 +00:00
=== === =
context . getObject ( ofd . id , read _file _data ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function read _data ( context , ofd , buffer , offset , length , position , callback ) {
var fileNode ;
var fileData ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function handle _file _data ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
fileData = result ;
if ( ! fileData ) {
return callback ( new Errors . EIO ( 'Expected Buffer' ) ) ;
}
var _position = ! ( undefined === position || null === position ) ? position : ofd . position ;
length = _position + length > buffer . length ? length - _position : length ;
fileData . copy ( buffer , offset , _position , _position + length ) ;
if ( undefined === position ) {
ofd . position += length ;
}
callback ( null , length ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function read _file _data ( error , result ) {
if ( error ) {
2014-05-27 18:44:30 +00:00
callback ( error ) ;
} else {
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
var stats = new Stats ( path , result , fs . name ) ;
2014-05-27 18:44:30 +00:00
callback ( null , stats ) ;
2018-06-28 17:35:20 +00:00
=== === =
fileNode = result ;
context . getBuffer ( fileNode . data , handle _file _data ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
return root + dir ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function basename ( path , ext ) {
var f = splitPath ( path ) [ 2 ] ;
// TODO: make this comparison case-insensitive on windows?
if ( ext && f . substr ( - 1 * ext . length ) === ext ) {
f = f . substr ( 0 , f . length - ext . length ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
// XXXfiler: node.js just does `return f`
return f === "" ? "/" : f ;
=== === =
context . getObject ( ofd . id , read _file _data ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
module . exports = {
2014-07-21 19:28:26 +00:00
ensureRootDirectory : ensure _root _directory ,
2014-05-27 18:44:30 +00:00
open : open ,
2018-05-29 18:03:59 +00:00
chmod : chmod ,
fchmod : fchmod ,
chown : chown ,
fchown : fchown ,
2014-05-27 18:44:30 +00:00
close : close ,
mknod : mknod ,
mkdir : mkdir ,
rmdir : rmdir ,
unlink : unlink ,
stat : stat ,
fstat : fstat ,
link : link ,
read : read ,
readFile : readFile ,
write : write ,
writeFile : writeFile ,
appendFile : appendFile ,
exists : exists ,
getxattr : getxattr ,
fgetxattr : fgetxattr ,
setxattr : setxattr ,
fsetxattr : fsetxattr ,
removexattr : removexattr ,
fremovexattr : fremovexattr ,
lseek : lseek ,
readdir : readdir ,
utimes : utimes ,
futimes : futimes ,
rename : rename ,
symlink : symlink ,
readlink : readlink ,
lstat : lstat ,
truncate : truncate ,
ftruncate : ftruncate
} ;
2018-06-28 17:35:20 +00:00
=== === =
function stat _file ( context , path , callback ) {
path = normalize ( path ) ;
var name = basename ( path ) ;
find _node ( context , path , standard _check _result _cb ( callback ) ) ;
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function fstat _file ( context , ofd , callback ) {
context . getObject ( ofd . id , standard _check _result _cb ( callback ) ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function lstat _file ( context , path , callback ) {
path = normalize ( path ) ;
var name = basename ( path ) ;
var parentPath = dirname ( path ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
// Make sure we don't double-add a trailing slash (e.g., '/' -> '//')
function addTrailing ( path ) {
return path . replace ( /\/*$/ , '/' ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Deal with multiple slashes at the end, one, or none
// and make sure we don't return the empty string.
function removeTrailing ( path ) {
path = path . replace ( /\/*$/ , '' ) ;
return path === '' ? '/' : path ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// XXXfiler: we don't support path.exists() or path.existsSync(), which
// are deprecated, and need a FileSystem instance to work. Use fs.stat().
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
module . exports = {
normalize : normalize ,
resolve : resolve ,
join : join ,
relative : relative ,
sep : '/' ,
delimiter : ':' ,
dirname : dirname ,
basename : basename ,
extname : extname ,
isAbsolute : isAbsolute ,
isNull : isNull ,
// Non-node but useful...
addTrailing : addTrailing ,
removeTrailing : removeTrailing
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
} , { } ] , 26 : [ function ( require , module , exports ) {
var IndexedDB = require ( './indexeddb.js' ) ;
var WebSQL = require ( './websql.js' ) ;
var Memory = require ( './memory.js' ) ;
=== === =
var directoryNode ;
var directoryData ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( ROOT _DIRECTORY _NAME == name ) {
find _node ( context , path , standard _check _result _cb ( callback ) ) ;
} else {
find _node ( context , parentPath , read _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function read _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryNode = result ;
context . getObject ( directoryNode . data , check _if _file _exists ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function check _if _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData = result ;
if ( ! _ ( directoryData ) . has ( name ) ) {
callback ( new Errors . ENOENT ( 'a component of the path does not name an existing file' , path ) ) ;
} else {
context . getObject ( directoryData [ name ] . id , standard _check _result _cb ( callback ) ) ;
}
}
2014-12-17 07:35:01 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
/ * *
* FileSystem
*
* A FileSystem takes an ` options ` object , which can specify a number of ,
* options . All options are optional , and include :
*
* name : the name of the file system , defaults to "local"
*
* flags : one or more flags to use when creating / opening the file system .
* For example : "FORMAT" will cause the file system to be formatted .
* No explicit flags are set by default .
*
* provider : an explicit storage provider to use for the file
* system ' s database context provider . A number of context
* providers are included ( see / src / providers ) , and users
* can write one of their own and pass it in to be used .
* By default an IndexedDB provider is used .
*
2014-07-14 20:01:52 +00:00
* guid : a function for generating unique IDs for nodes in the filesystem .
* Use this to override the built - in UUID generation . ( Used mainly for tests ) .
*
2014-05-27 18:44:30 +00:00
* callback : a callback function to be executed when the file system becomes
* ready for use . Depending on the context provider used , this might
* be right away , or could take some time . The callback should expect
* an ` error ` argument , which will be null if everything worked . Also
* users should check the file system ' s ` readyState ` and ` error `
* properties to make sure it is usable .
* /
function FileSystem ( options , callback ) {
options = options || { } ;
2014-12-17 07:35:01 +00:00
callback = callback || defaultCallback ;
2014-05-27 18:44:30 +00:00
var flags = options . flags ;
2014-07-14 20:01:52 +00:00
var guid = options . guid ? options . guid : defaultGuidFn ;
2014-05-27 18:44:30 +00:00
var provider = options . provider || new providers . Default ( options . name || FILE _SYSTEM _NAME ) ;
// If we're given a provider, match its name unless we get an explicit name
var name = options . name || provider . name ;
var forceFormatting = _ ( flags ) . contains ( FS _FORMAT ) ;
var fs = this ;
fs . readyState = FS _PENDING ;
fs . name = name ;
fs . error = null ;
fs . stdin = STDIN ;
fs . stdout = STDOUT ;
fs . stderr = STDERR ;
2018-05-29 18:03:59 +00:00
// Expose Node's fs.constants to users
fs . constants = Constants . fsConstants ;
2014-12-02 18:45:21 +00:00
// Expose Shell constructor
this . Shell = Shell . bind ( undefined , this ) ;
2018-06-28 17:35:20 +00:00
=== === =
function link _node ( context , oldpath , newpath , callback ) {
oldpath = normalize ( oldpath ) ;
var oldname = basename ( oldpath ) ;
var oldParentPath = dirname ( oldpath ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-12-02 18:45:21 +00:00
2018-06-28 17:35:20 +00:00
newpath = normalize ( newpath ) ;
var newname = basename ( newpath ) ;
var newParentPath = dirname ( newpath ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var oldDirectoryNode ;
var oldDirectoryData ;
var newDirectoryNode ;
var newDirectoryData ;
var fileNode ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
2014-05-27 18:44:30 +00:00
} else {
2018-06-28 17:35:20 +00:00
update _node _times ( context , newpath , fileNode , { ctime : Date . now ( ) } , callback ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function update _file _node ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
fileNode = result ;
fileNode . nlinks += 1 ;
context . putObject ( fileNode . id , fileNode , update _time ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
NotSupported . isSupported = function ( ) {
return false ;
2014-07-14 20:01:52 +00:00
} ;
2018-06-28 17:35:20 +00:00
return NotSupported ;
} ( ) )
} ;
2014-07-14 20:01:52 +00:00
2018-06-28 17:35:20 +00:00
} , { "./indexeddb.js" : 27 , "./memory.js" : 28 , "./websql.js" : 29 } ] , 27 : [ function ( require , module , exports ) {
( function ( global , Buffer ) {
var FILE _SYSTEM _NAME = require ( '../constants.js' ) . FILE _SYSTEM _NAME ;
var FILE _STORE _NAME = require ( '../constants.js' ) . FILE _STORE _NAME ;
var IDB _RW = require ( '../constants.js' ) . IDB _RW ;
var IDB _RO = require ( '../constants.js' ) . IDB _RO ;
var Errors = require ( '../errors.js' ) ;
var FilerBuffer = require ( '../buffer.js' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var indexedDB = global . indexedDB ||
global . mozIndexedDB ||
global . webkitIndexedDB ||
global . msIndexedDB ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function IndexedDBContext ( db , mode ) {
this . db = db ;
this . mode = mode ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
IndexedDBContext . prototype . _getObjectStore = function ( ) {
if ( this . objectStore ) {
return this . objectStore ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var transaction = this . db . transaction ( FILE _STORE _NAME , this . mode ) ;
this . objectStore = transaction . objectStore ( FILE _STORE _NAME ) ;
return this . objectStore ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
IndexedDBContext . prototype . clear = function ( callback ) {
try {
var objectStore = this . _getObjectStore ( ) ;
var request = objectStore . clear ( ) ;
request . onsuccess = function ( ) {
callback ( ) ;
} ;
request . onerror = function ( event ) {
event . preventDefault ( ) ;
callback ( event . error ) ;
} ;
} catch ( err ) {
callback ( err ) ;
=== === =
}
function read _directory _entry ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
context . getObject ( newDirectoryData [ newname ] . id , update _file _node ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
IndexedDBContext . prototype . _get = function ( key , callback ) {
try {
var objectStore = this . _getObjectStore ( ) ;
var request = objectStore . get ( key ) ;
request . onsuccess = function onsuccess ( event ) {
var result = event . target . result ;
callback ( null , result ) ;
} ;
request . onerror = function ( event ) {
event . preventDefault ( ) ;
callback ( event . error ) ;
} ;
} catch ( err ) {
callback ( err ) ;
}
} ;
IndexedDBContext . prototype . getObject = function ( key , callback ) {
this . _get ( key , callback ) ;
} ;
IndexedDBContext . prototype . getBuffer = function ( key , callback ) {
this . _get ( key , function ( err , arrayBuffer ) {
2014-05-27 18:44:30 +00:00
if ( err ) {
2018-06-28 17:35:20 +00:00
return callback ( err ) ;
=== === =
function check _if _new _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
newDirectoryData = result ;
if ( _ ( newDirectoryData ) . has ( newname ) ) {
callback ( new Errors . EEXIST ( 'newpath resolves to an existing file' , newname ) ) ;
} else {
newDirectoryData [ newname ] = oldDirectoryData [ oldname ] ;
context . putObject ( newDirectoryNode . data , newDirectoryData , read _directory _entry ) ;
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
IndexedDBContext . prototype . _put = function ( key , value , callback ) {
try {
var objectStore = this . _getObjectStore ( ) ;
var request = objectStore . put ( value , key ) ;
request . onsuccess = function onsuccess ( event ) {
var result = event . target . result ;
callback ( null , result ) ;
} ;
request . onerror = function ( event ) {
event . preventDefault ( ) ;
callback ( event . error ) ;
} ;
} catch ( err ) {
callback ( err ) ;
}
} ;
IndexedDBContext . prototype . putObject = function ( key , value , callback ) {
this . _put ( key , value , callback ) ;
} ;
IndexedDBContext . prototype . putBuffer = function ( key , uint8BackedBuffer , callback ) {
var buf ;
if ( ! Buffer . _useTypedArrays ) { // workaround for fxos 1.3
buf = uint8BackedBuffer . toArrayBuffer ( ) ;
} else {
buf = uint8BackedBuffer . buffer ;
}
this . _put ( key , buf , callback ) ;
} ;
2014-08-22 16:35:13 +00:00
2018-06-28 17:35:20 +00:00
IndexedDBContext . prototype . delete = function ( key , callback ) {
try {
var objectStore = this . _getObjectStore ( ) ;
var request = objectStore . delete ( key ) ;
request . onsuccess = function onsuccess ( event ) {
var result = event . target . result ;
callback ( null , result ) ;
} ;
request . onerror = function ( event ) {
event . preventDefault ( ) ;
callback ( event . error ) ;
} ;
} catch ( err ) {
callback ( err ) ;
=== === =
function read _new _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
2014-08-22 16:35:13 +00:00
} else {
2018-06-28 17:35:20 +00:00
newDirectoryNode = result ;
context . getObject ( newDirectoryNode . data , check _if _new _file _exists ) ;
2014-08-22 16:35:13 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function check _if _old _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
oldDirectoryData = result ;
if ( ! _ ( oldDirectoryData ) . has ( oldname ) ) {
callback ( new Errors . ENOENT ( 'a component of either path prefix does not exist' , oldname ) ) ;
} else {
find _node ( context , newParentPath , read _new _directory _data ) ;
}
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
/ * *
* Public API for FileSystem
* /
[
'open' ,
2018-05-29 18:03:59 +00:00
'chmod' ,
'fchmod' ,
'chown' ,
'fchown' ,
2014-05-27 18:44:30 +00:00
'close' ,
'mknod' ,
'mkdir' ,
'rmdir' ,
'stat' ,
'fstat' ,
'link' ,
'unlink' ,
'read' ,
'readFile' ,
'write' ,
'writeFile' ,
'appendFile' ,
'exists' ,
'lseek' ,
'readdir' ,
'rename' ,
'readlink' ,
'symlink' ,
'lstat' ,
'truncate' ,
'ftruncate' ,
'utimes' ,
'futimes' ,
'setxattr' ,
'getxattr' ,
'fsetxattr' ,
'fgetxattr' ,
'removexattr' ,
'fremovexattr'
] . forEach ( function ( methodName ) {
FileSystem . prototype [ methodName ] = function ( ) {
var fs = this ;
var args = Array . prototype . slice . call ( arguments , 0 ) ;
var lastArgIndex = args . length - 1 ;
2018-06-28 17:35:20 +00:00
=== === =
function read _old _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
oldDirectoryNode = result ;
context . getObject ( oldDirectoryNode . data , check _if _old _file _exists ) ;
}
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
find _node ( context , oldParentPath , read _old _directory _data ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
try {
// NOTE: we're not using versioned databases.
var openRequest = indexedDB . open ( that . name ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// If the db doesn't exist, we'll create it
openRequest . onupgradeneeded = function onupgradeneeded ( event ) {
var db = event . target . result ;
2014-08-18 18:40:44 +00:00
2018-06-28 17:35:20 +00:00
if ( db . objectStoreNames . contains ( FILE _STORE _NAME ) ) {
db . deleteObjectStore ( FILE _STORE _NAME ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
db . createObjectStore ( FILE _STORE _NAME ) ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
openRequest . onsuccess = function onsuccess ( event ) {
that . db = event . target . result ;
callback ( ) ;
} ;
openRequest . onerror = function onerror ( event ) {
event . preventDefault ( ) ;
callback ( event . error ) ;
} ;
} catch ( err ) {
callback ( err ) ;
}
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
IndexedDB . prototype . getReadOnlyContext = function ( ) {
return new IndexedDBContext ( this . db , IDB _RO ) ;
} ;
IndexedDB . prototype . getReadWriteContext = function ( ) {
return new IndexedDBContext ( this . db , IDB _RW ) ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
module . exports = IndexedDB ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
} ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } , require ( "buffer" ) . Buffer )
} , { "../buffer.js" : 14 , "../constants.js" : 15 , "../errors.js" : 18 , "buffer" : 6 } ] , 28 : [ function ( require , module , exports ) {
var FILE _SYSTEM _NAME = require ( '../constants.js' ) . FILE _SYSTEM _NAME ;
// NOTE: prefer setImmediate to nextTick for proper recursion yielding.
// see https://github.com/js-platform/filer/pull/24
var asyncCallback = require ( '../../lib/async.js' ) . setImmediate ;
=== === =
function unlink _node ( context , path , callback ) {
path = normalize ( path ) ;
var name = basename ( path ) ;
var parentPath = dirname ( path ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var directoryNode ;
var directoryData ;
var fileNode ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function update _directory _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
delete directoryData [ name ] ;
context . putObject ( directoryNode . data , directoryData , function ( error ) {
var now = Date . now ( ) ;
update _node _times ( context , parentPath , directoryNode , { mtime : now , ctime : now } , callback ) ;
} ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function delete _file _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
context . delete ( fileNode . data , update _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function update _file _node ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
fileNode = result ;
fileNode . nlinks -= 1 ;
if ( fileNode . nlinks < 1 ) {
context . delete ( fileNode . id , delete _file _data ) ;
} else {
context . putObject ( fileNode . id , fileNode , function ( error ) {
update _node _times ( context , path , fileNode , { ctime : Date . now ( ) } , update _directory _data ) ;
} ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-07-14 20:01:52 +00:00
2018-06-28 17:35:20 +00:00
function check _if _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData = result ;
if ( ! _ ( directoryData ) . has ( name ) ) {
callback ( new Errors . ENOENT ( 'a component of the path does not name an existing file' , name ) ) ;
} else {
context . getObject ( directoryData [ name ] . id , update _file _node ) ;
}
2014-07-15 13:26:58 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function read _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryNode = result ;
context . getObject ( directoryNode . data , check _if _file _exists ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
find _node ( context , parentPath , read _directory _data ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function read _directory ( context , path , callback ) {
path = normalize ( path ) ;
var name = basename ( path ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var directoryNode ;
var directoryData ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
} , { "./buffer.js" : 14 , "./errors.js" : 18 , "./filesystem/interface.js" : 20 , "./path.js" : 25 , "./shell/shell.js" : 32 } ] , 23 : [ function ( require , module , exports ) {
2018-05-29 18:03:59 +00:00
var NODE _TYPE _FILE = require ( './constants.js' ) . NODE _TYPE _FILE ;
var NODE _TYPE _DIRECTORY = require ( './constants.js' ) . NODE _TYPE _DIRECTORY ;
var NODE _TYPE _SYMBOLIC _LINK = require ( './constants.js' ) . NODE _TYPE _SYMBOLIC _LINK ;
var NODE _TYPE _META = require ( './constants.js' ) . NODE _TYPE _META ;
var ROOT _DIRECTORY _NAME = require ( './constants.js' ) . ROOT _DIRECTORY _NAME ;
var S _IFREG = require ( './constants.js' ) . S _IFREG ;
var S _IFDIR = require ( './constants.js' ) . S _IFDIR ;
var S _IFLNK = require ( './constants.js' ) . S _IFLNK ;
var DEFAULT _FILE _PERMISSIONS = require ( './constants.js' ) . DEFAULT _FILE _PERMISSIONS ;
var DEFAULT _DIR _PERMISSIONS = require ( './constants.js' ) . DEFAULT _DIR _PERMISSIONS ;
function getMode ( type , mode ) {
switch ( type ) {
case NODE _TYPE _DIRECTORY :
return ( mode || DEFAULT _DIR _PERMISSIONS ) | S _IFDIR ;
case NODE _TYPE _SYMBOLIC _LINK :
return ( mode || DEFAULT _FILE _PERMISSIONS ) | S _IFLNK ;
/* jshint -W086 */
case NODE _TYPE _FILE :
// falls through
default :
return ( mode || DEFAULT _FILE _PERMISSIONS ) | S _IFREG ;
}
}
2018-06-28 17:35:20 +00:00
=== === =
<< << << < HEAD
} , { "../../lib/async.js" : 1 , "../constants.js" : 15 } ] , 29 : [ function ( require , module , exports ) {
( function ( global ) {
var FILE _SYSTEM _NAME = require ( '../constants.js' ) . FILE _SYSTEM _NAME ;
var FILE _STORE _NAME = require ( '../constants.js' ) . FILE _STORE _NAME ;
var WSQL _VERSION = require ( '../constants.js' ) . WSQL _VERSION ;
var WSQL _SIZE = require ( '../constants.js' ) . WSQL _SIZE ;
var WSQL _DESC = require ( '../constants.js' ) . WSQL _DESC ;
var Errors = require ( '../errors.js' ) ;
var FilerBuffer = require ( '../buffer.js' ) ;
var base64ArrayBuffer = require ( 'base64-arraybuffer' ) ;
=== === =
function handle _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData = result ;
var files = Object . keys ( directoryData ) ;
callback ( null , files ) ;
}
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function read _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
} else if ( result . mode !== MODE _DIRECTORY ) {
callback ( new Errors . ENOTDIR ( null , path ) ) ;
} else {
directoryNode = result ;
context . getObject ( directoryNode . data , handle _directory _data ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-07-14 20:01:52 +00:00
this . id = options . id ;
2018-05-29 18:03:59 +00:00
this . type = options . type || NODE _TYPE _FILE ; // node type (file, directory, etc)
2014-07-14 20:01:52 +00:00
this . size = options . size || 0 ; // size (bytes for files, entries for directories)
this . atime = options . atime || now ; // access time (will mirror ctime after creation)
this . ctime = options . ctime || now ; // creation/change time
this . mtime = options . mtime || now ; // modified time
this . flags = options . flags || [ ] ; // file flags
this . xattrs = options . xattrs || { } ; // extended attributes
this . nlinks = options . nlinks || 0 ; // links count
this . data = options . data ; // id for data object
2018-05-29 18:03:59 +00:00
this . version = options . version || 1 ;
// permissions and flags
this . mode = options . mode || ( getMode ( this . type ) ) ;
this . uid = options . uid || 0x0 ; // owner name
this . gid = options . gid || 0x0 ; // group name
2018-06-28 17:35:20 +00:00
=== === =
find _node ( context , path , read _directory _data ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-07-14 20:01:52 +00:00
}
2018-06-28 17:35:20 +00:00
function make _symbolic _link ( context , srcpath , dstpath , callback ) {
dstpath = normalize ( dstpath ) ;
var name = basename ( dstpath ) ;
var parentPath = dirname ( dstpath ) ;
var directoryNode ;
var directoryData ;
var fileNode ;
if ( ROOT _DIRECTORY _NAME == name ) {
callback ( new Errors . EEXIST ( null , name ) ) ;
2014-07-14 20:01:52 +00:00
} else {
2018-06-28 17:35:20 +00:00
find _node ( context , parentPath , read _directory _data ) ;
2014-07-14 20:01:52 +00:00
}
2018-06-28 17:35:20 +00:00
function read _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryNode = result ;
context . getObject ( directoryNode . data , check _if _file _exists ) ;
2014-07-14 20:01:52 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-07-14 20:01:52 +00:00
2018-06-28 17:35:20 +00:00
function check _if _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData = result ;
if ( _ ( directoryData ) . has ( name ) ) {
callback ( new Errors . EEXIST ( null , name ) ) ;
} else {
write _file _node ( ) ;
2014-07-14 20:01:52 +00:00
}
2018-06-28 17:35:20 +00:00
}
}
2014-07-14 20:01:52 +00:00
2018-06-28 17:35:20 +00:00
function write _file _node ( ) {
Node . create ( { guid : context . guid , mode : MODE _SYMBOLIC _LINK } , function ( error , result ) {
if ( error ) {
callback ( error ) ;
return ;
}
fileNode = result ;
fileNode . nlinks += 1 ;
fileNode . size = srcpath . length ;
fileNode . data = srcpath ;
context . putObject ( fileNode . id , fileNode , update _directory _data ) ;
2014-07-14 20:01:52 +00:00
} ) ;
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-07-14 20:01:52 +00:00
} ) ;
2014-05-27 18:44:30 +00:00
} ;
2018-05-29 18:03:59 +00:00
// Update the node's mode (permissions), taking file type bits into account.
Node . setMode = function ( mode , node ) {
node . mode = getMode ( node . type , mode ) ;
} ;
2014-07-14 20:01:52 +00:00
module . exports = Node ;
2015-06-29 16:29:46 +00:00
} , { "./constants.js" : 15 } ] , 24 : [ function ( require , module , exports ) {
var Errors = require ( './errors.js' ) ;
2014-10-24 11:56:16 +00:00
function OpenFileDescription ( path , id , flags , position ) {
2014-05-27 18:44:30 +00:00
this . path = path ;
this . id = id ;
this . flags = flags ;
this . position = position ;
2014-10-24 11:56:16 +00:00
}
// Tries to find the node associated with an ofd's `id`.
// If not found, an error is returned on the callback.
OpenFileDescription . prototype . getNode = function ( context , callback ) {
var id = this . id ;
var path = this . path ;
2018-06-28 17:35:20 +00:00
=== === =
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-10-24 11:56:16 +00:00
2018-06-28 17:35:20 +00:00
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
} else {
var now = Date . now ( ) ;
update _node _times ( context , parentPath , directoryNode , { mtime : now , ctime : now } , callback ) ;
2014-10-24 11:56:16 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-10-24 11:56:16 +00:00
2018-06-28 17:35:20 +00:00
function update _directory _data ( error ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData [ name ] = new DirectoryEntry ( fileNode . id , MODE _SYMBOLIC _LINK ) ;
context . putObject ( directoryNode . data , directoryData , update _time ) ;
2014-10-24 11:56:16 +00:00
}
}
2018-06-28 17:35:20 +00:00
}
2014-10-24 11:56:16 +00:00
2018-06-28 17:35:20 +00:00
function read _link ( context , path , callback ) {
path = normalize ( path ) ;
var name = basename ( path ) ;
var parentPath = dirname ( path ) ;
2014-10-24 11:56:16 +00:00
2018-06-28 17:35:20 +00:00
var directoryNode ;
var directoryData ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
find _node ( context , parentPath , read _directory _data ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function read _directory _data ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryNode = result ;
context . getObject ( directoryNode . data , check _if _file _exists ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function check _if _file _exists ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
directoryData = result ;
if ( ! _ ( directoryData ) . has ( name ) ) {
callback ( new Errors . ENOENT ( 'a component of the path does not name an existing file' , name ) ) ;
} else {
context . getObject ( directoryData [ name ] . id , check _if _symbolic ) ;
}
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function check _if _symbolic ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
if ( result . mode != MODE _SYMBOLIC _LINK ) {
callback ( new Errors . EINVAL ( 'path not a symbolic link' , path ) ) ;
} else {
callback ( null , result . data ) ;
}
}
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function truncate _file ( context , path , length , callback ) {
path = normalize ( path ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var fileNode ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function read _file _data ( error , node ) {
if ( error ) {
callback ( error ) ;
} else if ( node . mode == MODE _DIRECTORY ) {
callback ( new Errors . EISDIR ( null , path ) ) ;
} else {
fileNode = node ;
context . getBuffer ( fileNode . data , truncate _file _data ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function truncate _file _data ( error , fileData ) {
if ( error ) {
callback ( error ) ;
} else {
if ( ! fileData ) {
return callback ( new Errors . EIO ( 'Expected Buffer' ) ) ;
}
var data = new Buffer ( length ) ;
data . fill ( 0 ) ;
if ( fileData ) {
fileData . copy ( data ) ;
}
context . putBuffer ( fileNode . data , data , update _file _node ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
} else {
var now = Date . now ( ) ;
update _node _times ( context , path , fileNode , { mtime : now , ctime : now } , callback ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function update _file _node ( error ) {
if ( error ) {
callback ( error ) ;
} else {
fileNode . size = length ;
fileNode . version += 1 ;
context . putObject ( fileNode . id , fileNode , update _time ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
} ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } )
} , { "../buffer.js" : 14 , "../constants.js" : 15 , "../errors.js" : 18 , "base64-arraybuffer" : 5 } ] , 30 : [ function ( require , module , exports ) {
function guid ( ) {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' . replace ( /[xy]/g , function ( c ) {
var r = Math . random ( ) * 16 | 0 , v = c == 'x' ? r : ( r & 0x3 | 0x8 ) ;
return v . toString ( 16 ) ;
} ) . toUpperCase ( ) ;
=== === =
if ( length < 0 ) {
callback ( new Errors . EINVAL ( 'length cannot be negative' ) ) ;
} else {
find _node ( context , path , read _file _data ) ;
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function ftruncate _file ( context , ofd , length , callback ) {
var fileNode ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function read _file _data ( error , node ) {
if ( error ) {
callback ( error ) ;
} else if ( node . mode == MODE _DIRECTORY ) {
callback ( new Errors . EISDIR ( ) ) ;
} else {
fileNode = node ;
context . getBuffer ( fileNode . data , truncate _file _data ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function truncate _file _data ( error , fileData ) {
if ( error ) {
callback ( error ) ;
} else {
var data ;
if ( ! fileData ) {
return callback ( new Errors . EIO ( 'Expected Buffer' ) ) ;
}
if ( fileData ) {
data = fileData . slice ( 0 , length ) ;
} else {
data = new Buffer ( length ) ;
data . fill ( 0 ) ;
}
context . putBuffer ( fileNode . data , data , update _file _node ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
} , { } ] , 31 : [ function ( require , module , exports ) {
var defaults = require ( '../constants.js' ) . ENVIRONMENT ;
=== === =
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
} else {
var now = Date . now ( ) ;
update _node _times ( context , ofd . path , fileNode , { mtime : now , ctime : now } , callback ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function update _file _node ( error ) {
if ( error ) {
callback ( error ) ;
} else {
fileNode . size = length ;
fileNode . version += 1 ;
context . putObject ( fileNode . id , fileNode , update _time ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
if ( length < 0 ) {
callback ( new Errors . EINVAL ( 'length cannot be negative' ) ) ;
} else {
context . getObject ( ofd . id , read _file _data ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function utimes _file ( context , path , atime , mtime , callback ) {
path = normalize ( path ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
} , { "../constants.js" : 15 } ] , 32 : [ function ( require , module , exports ) {
var Path = require ( '../path.js' ) ;
var Errors = require ( '../errors.js' ) ;
var Environment = require ( './environment.js' ) ;
var async = require ( '../../lib/async.js' ) ;
var Encoding = require ( '../encoding.js' ) ;
var minimatch = require ( 'minimatch' ) ;
=== === =
function update _times ( error , node ) {
if ( error ) {
callback ( error ) ;
} else {
update _node _times ( context , path , node , { atime : atime , ctime : mtime , mtime : mtime } , callback ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( typeof atime != 'number' || typeof mtime != 'number' ) {
callback ( new Errors . EINVAL ( 'atime and mtime must be number' , path ) ) ;
} else if ( atime < 0 || mtime < 0 ) {
callback ( new Errors . EINVAL ( 'atime and mtime must be positive integers' , path ) ) ;
} else {
find _node ( context , path , update _times ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function futimes _file ( context , ofd , atime , mtime , callback ) {
function update _times ( error , node ) {
if ( error ) {
callback ( error ) ;
} else {
update _node _times ( context , ofd . path , node , { atime : atime , ctime : mtime , mtime : mtime } , callback ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
if ( typeof atime != 'number' || typeof mtime != 'number' ) {
callback ( new Errors . EINVAL ( 'atime and mtime must be a number' ) ) ;
} else if ( atime < 0 || mtime < 0 ) {
callback ( new Errors . EINVAL ( 'atime and mtime must be positive integers' ) ) ;
} else {
context . getObject ( ofd . id , update _times ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function setxattr _file ( context , path , name , value , flag , callback ) {
path = normalize ( path ) ;
if ( typeof name != 'string' ) {
callback ( new Errors . EINVAL ( 'attribute name must be a string' , path ) ) ;
} else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' , path ) ) ;
} else if ( flag !== null && flag !== XATTR _CREATE && flag !== XATTR _REPLACE ) {
callback ( new Errors . EINVAL ( 'invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE' , path ) ) ;
} else {
set _extended _attribute ( context , path , name , value , flag , callback ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function fsetxattr _file ( context , ofd , name , value , flag , callback ) {
if ( typeof name != 'string' ) {
callback ( new Errors . EINVAL ( 'attribute name must be a string' ) ) ;
} else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' ) ) ;
} else if ( flag !== null && flag !== XATTR _CREATE && flag !== XATTR _REPLACE ) {
callback ( new Errors . EINVAL ( 'invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE' ) ) ;
} else {
set _extended _attribute ( context , ofd , name , value , flag , callback ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function getxattr _file ( context , path , name , callback ) {
path = normalize ( path ) ;
2014-12-02 18:45:21 +00:00
2018-06-28 17:35:20 +00:00
function get _xattr ( error , node ) {
var xattr = node ? node . xattrs [ name ] : null ;
if ( error ) {
callback ( error ) ;
} else if ( ! node . xattrs . hasOwnProperty ( name ) ) {
callback ( new Errors . ENOATTR ( null , path ) ) ;
} else {
callback ( null , node . xattrs [ name ] ) ;
}
}
if ( typeof name != 'string' ) {
callback ( new Errors . EINVAL ( 'attribute name must be a string' , path ) ) ;
} else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' , path ) ) ;
} else {
find _node ( context , path , get _xattr ) ;
}
2014-12-02 18:45:21 +00:00
}
2018-06-28 17:35:20 +00:00
function fgetxattr _file ( context , ofd , name , callback ) {
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function get _xattr ( error , node ) {
var xattr = node ? node . xattrs [ name ] : null ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( error ) {
callback ( error ) ;
} else if ( ! node . xattrs . hasOwnProperty ( name ) ) {
callback ( new Errors . ENOATTR ( ) ) ;
} else {
callback ( null , node . xattrs [ name ] ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( typeof name != 'string' ) {
callback ( new Errors . EINVAL ( ) ) ;
} else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' ) ) ;
} else {
context . getObject ( ofd . id , get _xattr ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function removexattr _file ( context , path , name , callback ) {
path = normalize ( path ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function remove _xattr ( error , node ) {
var xattr = node ? node . xattrs : null ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
} else {
update _node _times ( context , path , node , { ctime : Date . now ( ) } , callback ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
if ( error ) {
callback ( error ) ;
} else if ( ! xattr . hasOwnProperty ( name ) ) {
callback ( new Errors . ENOATTR ( null , path ) ) ;
} else {
delete node . xattrs [ name ] ;
context . putObject ( node . id , node , update _time ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( typeof name != 'string' ) {
callback ( new Errors . EINVAL ( 'attribute name must be a string' , path ) ) ;
} else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' , path ) ) ;
} else {
find _node ( context , path , remove _xattr ) ;
}
}
function fremovexattr _file ( context , ofd , name , callback ) {
function remove _xattr ( error , node ) {
function update _time ( error ) {
if ( error ) {
callback ( error ) ;
} else {
update _node _times ( context , ofd . path , node , { ctime : Date . now ( ) } , callback ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
} , { "./indexeddb.js" : 27 , "./memory.js" : 28 , "./websql.js" : 29 } ] , 27 : [ function ( require , module , exports ) {
2018-05-29 18:03:59 +00:00
( function ( global ) {
2015-06-29 16:29:46 +00:00
var FILE _SYSTEM _NAME = require ( '../constants.js' ) . FILE _SYSTEM _NAME ;
var FILE _STORE _NAME = require ( '../constants.js' ) . FILE _STORE _NAME ;
var IDB _RW = require ( '../constants.js' ) . IDB _RW ;
var IDB _RO = require ( '../constants.js' ) . IDB _RO ;
var Errors = require ( '../errors.js' ) ;
var FilerBuffer = require ( '../buffer.js' ) ;
2018-06-28 17:35:20 +00:00
=== === =
if ( error ) {
callback ( error ) ;
} else if ( ! node . xattrs . hasOwnProperty ( name ) ) {
callback ( new Errors . ENOATTR ( ) ) ;
} else {
delete node . xattrs [ name ] ;
context . putObject ( node . id , node , update _time ) ;
}
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( typeof name != 'string' ) {
callback ( new Errors . EINVAL ( 'attribute name must be a string' ) ) ;
} else if ( ! name ) {
callback ( new Errors . EINVAL ( 'attribute name cannot be an empty string' ) ) ;
} else {
context . getObject ( ofd . id , remove _xattr ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function validate _flags ( flags ) {
if ( ! _ ( O _FLAGS ) . has ( flags ) ) {
return null ;
}
return O _FLAGS [ flags ] ;
2014-06-23 18:31:58 +00:00
}
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
function validate _file _options ( options , enc , fileMode ) {
if ( ! options ) {
options = { encoding : enc , flag : fileMode } ;
} else if ( typeof options === "function" ) {
options = { encoding : enc , flag : fileMode } ;
} else if ( typeof options === "string" ) {
options = { encoding : options , flag : fileMode } ;
2017-05-25 14:05:32 +00:00
}
2018-06-28 17:35:20 +00:00
return options ;
}
2017-05-25 14:05:32 +00:00
2018-06-28 17:35:20 +00:00
function pathCheck ( path , callback ) {
var err ;
2017-05-25 14:05:32 +00:00
2018-06-28 17:35:20 +00:00
if ( ! path ) {
err = new Errors . EINVAL ( 'Path must be a string' , path ) ;
} else if ( isNullPath ( path ) ) {
err = new Errors . EINVAL ( 'Path must be a string without null bytes.' , path ) ;
} else if ( ! isAbsolutePath ( path ) ) {
err = new Errors . EINVAL ( 'Path must be absolute.' , path ) ;
2014-05-27 18:44:30 +00:00
}
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
if ( err ) {
2017-05-25 14:05:32 +00:00
callback ( err ) ;
2018-06-28 17:35:20 +00:00
return false ;
2014-06-23 18:31:58 +00:00
}
2018-06-28 17:35:20 +00:00
return true ;
}
function open ( fs , context , path , flags , mode , callback ) {
// NOTE: we support the same signature as node with a `mode` arg,
// but ignore it.
callback = arguments [ arguments . length - 1 ] ;
if ( ! pathCheck ( path , callback ) ) return ;
function check _result ( error , fileNode ) {
if ( error ) {
callback ( error ) ;
} else {
var position ;
if ( _ ( flags ) . contains ( O _APPEND ) ) {
position = fileNode . size ;
} else {
position = 0 ;
}
var openFileDescription = new OpenFileDescription ( path , fileNode . id , flags , position ) ;
var fd = fs . allocDescriptor ( openFileDescription ) ;
callback ( null , fd ) ;
2014-08-17 05:56:03 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
flags = validate _flags ( flags ) ;
if ( ! flags ) {
callback ( new Errors . EINVAL ( 'flags is not valid' ) , path ) ;
2014-06-23 18:31:58 +00:00
}
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2017-05-25 14:05:32 +00:00
} ;
2014-08-17 05:56:03 +00:00
IndexedDBContext . prototype . putObject = function ( key , value , callback ) {
2017-05-25 14:05:32 +00:00
this . _put ( key , value , callback ) ;
2014-08-17 05:56:03 +00:00
} ;
IndexedDBContext . prototype . putBuffer = function ( key , uint8BackedBuffer , callback ) {
2018-05-29 18:03:59 +00:00
var buf = uint8BackedBuffer . buffer ;
2017-05-25 14:05:32 +00:00
this . _put ( key , buf , callback ) ;
2014-06-23 18:31:58 +00:00
} ;
2018-06-28 17:35:20 +00:00
=== === =
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
open _file ( context , path , flags , check _result ) ;
}
function close ( fs , context , fd , callback ) {
if ( ! _ ( fs . openFiles ) . has ( fd ) ) {
callback ( new Errors . EBADF ( ) ) ;
} else {
fs . releaseDescriptor ( fd ) ;
callback ( null ) ;
2014-06-23 18:31:58 +00:00
}
2018-06-28 17:35:20 +00:00
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
function mknod ( fs , context , path , mode , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
make _node ( context , path , mode , callback ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function mkdir ( fs , context , path , mode , callback ) {
// NOTE: we support passing a mode arg, but we ignore it internally for now.
callback = arguments [ arguments . length - 1 ] ;
if ( ! pathCheck ( path , callback ) ) return ;
make _directory ( context , path , standard _check _result _cb ( callback ) ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function rmdir ( fs , context , path , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
remove _directory ( context , path , standard _check _result _cb ( callback ) ) ;
}
function stat ( fs , context , path , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
function check _result ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
var stats = new Stats ( result , fs . name ) ;
callback ( null , stats ) ;
}
}
stat _file ( context , path , check _result ) ;
}
function fstat ( fs , context , fd , callback ) {
function check _result ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
var stats = new Stats ( result , fs . name ) ;
callback ( null , stats ) ;
}
}
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else {
fstat _file ( context , ofd , check _result ) ;
}
}
function link ( fs , context , oldpath , newpath , callback ) {
if ( ! pathCheck ( oldpath , callback ) ) return ;
if ( ! pathCheck ( newpath , callback ) ) return ;
link _node ( context , oldpath , newpath , standard _check _result _cb ( callback ) ) ;
}
function unlink ( fs , context , path , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
unlink _node ( context , path , standard _check _result _cb ( callback ) ) ;
}
function read ( fs , context , fd , buffer , offset , length , position , callback ) {
// Follow how node.js does this
function wrapped _cb ( err , bytesRead ) {
// Retain a reference to buffer so that it can't be GC'ed too soon.
callback ( err , bytesRead || 0 , buffer ) ;
}
offset = undefined === offset ? 0 : offset ;
length = undefined === length ? buffer . length - offset : length ;
callback = arguments [ arguments . length - 1 ] ;
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else if ( ! _ ( ofd . flags ) . contains ( O _READ ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit reading' ) ) ;
} else {
read _data ( context , ofd , buffer , offset , length , position , standard _check _result _cb ( wrapped _cb ) ) ;
}
2014-06-23 18:31:58 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function readFile ( fs , context , path , options , callback ) {
callback = arguments [ arguments . length - 1 ] ;
options = validate _file _options ( options , null , 'r' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( ! pathCheck ( path , callback ) ) return ;
var flags = validate _flags ( options . flag || 'r' ) ;
if ( ! flags ) {
return callback ( new Errors . EINVAL ( 'flags is not valid' , path ) ) ;
2014-06-23 18:31:58 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
open _file ( context , path , flags , function ( err , fileNode ) {
if ( err ) {
return callback ( err ) ;
}
var ofd = new OpenFileDescription ( path , fileNode . id , flags , 0 ) ;
var fd = fs . allocDescriptor ( ofd ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function cleanup ( ) {
fs . releaseDescriptor ( fd ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
fstat _file ( context , ofd , function ( err , fstatResult ) {
if ( err ) {
cleanup ( ) ;
return callback ( err ) ;
2017-05-25 14:05:32 +00:00
}
2014-06-23 18:31:58 +00:00
2018-06-28 17:35:20 +00:00
var stats = new Stats ( fstatResult , fs . name ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
} ) . call ( this , typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : { } )
} , { "../buffer.js" : 14 , "../constants.js" : 15 , "../errors.js" : 18 } ] , 28 : [ function ( require , module , exports ) {
2015-06-29 16:29:46 +00:00
var FILE _SYSTEM _NAME = require ( '../constants.js' ) . FILE _SYSTEM _NAME ;
2014-07-21 19:28:26 +00:00
// NOTE: prefer setImmediate to nextTick for proper recursion yielding.
// see https://github.com/js-platform/filer/pull/24
2015-06-29 16:29:46 +00:00
var asyncCallback = require ( '../../lib/async.js' ) . setImmediate ;
2018-06-28 17:35:20 +00:00
=== === =
if ( stats . isDirectory ( ) ) {
cleanup ( ) ;
return callback ( new Errors . EISDIR ( 'illegal operation on directory' , path ) ) ;
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var size = stats . size ;
var buffer = new Buffer ( size ) ;
buffer . fill ( 0 ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
read _data ( context , ofd , buffer , 0 , size , 0 , function ( err , nbytes ) {
cleanup ( ) ;
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
if ( err ) {
return callback ( err ) ;
}
var data ;
if ( options . encoding === 'utf8' ) {
data = Encoding . decode ( buffer ) ;
} else {
data = buffer ;
}
callback ( null , data ) ;
} ) ;
2014-05-27 18:44:30 +00:00
} ) ;
} ) ;
2018-06-28 17:35:20 +00:00
}
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
function write ( fs , context , fd , buffer , offset , length , position , callback ) {
callback = arguments [ arguments . length - 1 ] ;
offset = undefined === offset ? 0 : offset ;
length = undefined === length ? buffer . length - offset : length ;
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else if ( ! _ ( ofd . flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit writing' ) ) ;
} else if ( buffer . length - offset < length ) {
callback ( new Errors . EIO ( 'intput buffer is too small' ) ) ;
} else {
write _data ( context , ofd , buffer , offset , length , position , standard _check _result _cb ( callback ) ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function writeFile ( fs , context , path , data , options , callback ) {
callback = arguments [ arguments . length - 1 ] ;
options = validate _file _options ( options , 'utf8' , 'w' ) ;
2014-06-23 18:31:58 +00:00
2018-06-28 17:35:20 +00:00
if ( ! pathCheck ( path , callback ) ) return ;
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
var flags = validate _flags ( options . flag || 'w' ) ;
if ( ! flags ) {
return callback ( new Errors . EINVAL ( 'flags is not valid' , path ) ) ;
2014-06-23 18:31:58 +00:00
}
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
data = data || '' ;
if ( typeof data === "number" ) {
data = '' + data ;
2014-06-23 18:31:58 +00:00
}
2018-06-28 17:35:20 +00:00
if ( typeof data === "string" && options . encoding === 'utf8' ) {
data = Encoding . encode ( data ) ;
2014-06-23 18:31:58 +00:00
}
2018-06-28 17:35:20 +00:00
open _file ( context , path , flags , function ( err , fileNode ) {
if ( err ) {
2014-08-17 05:56:03 +00:00
return callback ( err ) ;
}
2018-06-28 17:35:20 +00:00
var ofd = new OpenFileDescription ( path , fileNode . id , flags , 0 ) ;
var fd = fs . allocDescriptor ( ofd ) ;
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
replace _data ( context , ofd , data , 0 , data . length , function ( err , nbytes ) {
fs . releaseDescriptor ( fd ) ;
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
if ( err ) {
return callback ( err ) ;
}
callback ( null ) ;
} ) ;
2014-08-17 05:56:03 +00:00
} ) ;
2018-06-28 17:35:20 +00:00
}
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
function appendFile ( fs , context , path , data , options , callback ) {
callback = arguments [ arguments . length - 1 ] ;
options = validate _file _options ( options , 'utf8' , 'a' ) ;
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
if ( ! pathCheck ( path , callback ) ) return ;
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
var flags = validate _flags ( options . flag || 'a' ) ;
if ( ! flags ) {
return callback ( new Errors . EINVAL ( 'flags is not valid' , path ) ) ;
2014-06-23 18:31:58 +00:00
}
2014-08-17 05:56:03 +00:00
2018-06-28 17:35:20 +00:00
data = data || '' ;
if ( typeof data === "number" ) {
data = '' + data ;
2014-06-23 18:31:58 +00:00
}
2018-06-28 17:35:20 +00:00
if ( typeof data === "string" && options . encoding === 'utf8' ) {
data = Encoding . encode ( data ) ;
2014-06-23 18:31:58 +00:00
}
2018-06-28 17:35:20 +00:00
open _file ( context , path , flags , function ( err , fileNode ) {
if ( err ) {
return callback ( err ) ;
}
var ofd = new OpenFileDescription ( path , fileNode . id , flags , fileNode . size ) ;
var fd = fs . allocDescriptor ( ofd ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
write _data ( context , ofd , data , 0 , data . length , ofd . position , function ( err , nbytes ) {
fs . releaseDescriptor ( fd ) ;
if ( err ) {
return callback ( err ) ;
}
callback ( null ) ;
} ) ;
} ) ;
}
function exists ( fs , context , path , callback ) {
function cb ( err , stats ) {
callback ( err ? false : true ) ;
}
stat ( fs , context , path , cb ) ;
2014-06-23 18:31:58 +00:00
}
2018-06-28 17:35:20 +00:00
function getxattr ( fs , context , path , name , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
getxattr _file ( context , path , name , standard _check _result _cb ( callback ) ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function fgetxattr ( fs , context , fd , name , callback ) {
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else {
fgetxattr _file ( context , ofd , name , standard _check _result _cb ( callback ) ) ;
2014-06-23 18:31:58 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function setxattr ( fs , context , path , name , value , flag , callback ) {
if ( typeof flag === 'function' ) {
callback = flag ;
flag = null ;
2014-06-23 18:31:58 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( ! pathCheck ( path , callback ) ) return ;
setxattr _file ( context , path , name , value , flag , standard _check _result _cb ( callback ) ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function fsetxattr ( fs , context , fd , name , value , flag , callback ) {
if ( typeof flag === 'function' ) {
callback = flag ;
flag = null ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else if ( ! _ ( ofd . flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit writing' ) ) ;
} else {
fsetxattr _file ( context , ofd , name , value , flag , standard _check _result _cb ( callback ) ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function removexattr ( fs , context , path , name , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
removexattr _file ( context , path , name , standard _check _result _cb ( callback ) ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function fremovexattr ( fs , context , fd , name , callback ) {
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else if ( ! _ ( ofd . flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit writing' ) ) ;
} else {
fremovexattr _file ( context , ofd , name , standard _check _result _cb ( callback ) ) ;
2014-05-27 18:44:30 +00:00
}
}
2018-06-28 17:35:20 +00:00
function lseek ( fs , context , fd , offset , whence , callback ) {
function update _descriptor _position ( error , stats ) {
if ( error ) {
callback ( error ) ;
} else {
if ( stats . size + offset < 0 ) {
callback ( new Errors . EINVAL ( 'resulting file offset would be negative' ) ) ;
} else {
ofd . position = stats . size + offset ;
callback ( null , ofd . position ) ;
}
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( 'SET' === whence ) {
if ( offset < 0 ) {
callback ( new Errors . EINVAL ( 'resulting file offset would be negative' ) ) ;
} else {
ofd . position = offset ;
callback ( null , ofd . position ) ;
}
} else if ( 'CUR' === whence ) {
if ( ofd . position + offset < 0 ) {
callback ( new Errors . EINVAL ( 'resulting file offset would be negative' ) ) ;
} else {
ofd . position += offset ;
callback ( null , ofd . position ) ;
}
} else if ( 'END' === whence ) {
fstat _file ( context , ofd , update _descriptor _position ) ;
} else {
callback ( new Errors . EINVAL ( 'whence argument is not a proper value' ) ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function readdir ( fs , context , path , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
read _directory ( context , path , standard _check _result _cb ( callback ) ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function utimes ( fs , context , path , atime , mtime , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var currentTime = Date . now ( ) ;
atime = atime ? atime : currentTime ;
mtime = mtime ? mtime : currentTime ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
utimes _file ( context , path , atime , mtime , standard _check _result _cb ( callback ) ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function futimes ( fs , context , fd , atime , mtime , callback ) {
var currentTime = Date . now ( ) ;
atime = atime ? atime : currentTime ;
mtime = mtime ? mtime : currentTime ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else if ( ! _ ( ofd . flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit writing' ) ) ;
} else {
futimes _file ( context , ofd , atime , mtime , standard _check _result _cb ( callback ) ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function rename ( fs , context , oldpath , newpath , callback ) {
if ( ! pathCheck ( oldpath , callback ) ) return ;
if ( ! pathCheck ( newpath , callback ) ) return ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function unlink _old _node ( error ) {
if ( error ) {
callback ( error ) ;
} else {
unlink _node ( context , oldpath , standard _check _result _cb ( callback ) ) ;
}
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
link _node ( context , oldpath , newpath , unlink _old _node ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
function symlink ( fs , context , srcpath , dstpath , type , callback ) {
// NOTE: we support passing the `type` arg, but ignore it.
callback = arguments [ arguments . length - 1 ] ;
if ( ! pathCheck ( srcpath , callback ) ) return ;
if ( ! pathCheck ( dstpath , callback ) ) return ;
make _symbolic _link ( context , srcpath , dstpath , standard _check _result _cb ( callback ) ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function readlink ( fs , context , path , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
read _link ( context , path , standard _check _result _cb ( callback ) ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function lstat ( fs , context , path , callback ) {
if ( ! pathCheck ( path , callback ) ) return ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function check _result ( error , result ) {
if ( error ) {
callback ( error ) ;
} else {
var stats = new Stats ( result , fs . name ) ;
callback ( null , stats ) ;
}
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
lstat _file ( context , path , check _result ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
function truncate ( fs , context , path , length , callback ) {
// NOTE: length is optional
callback = arguments [ arguments . length - 1 ] ;
length = length || 0 ;
if ( ! pathCheck ( path , callback ) ) return ;
truncate _file ( context , path , length , standard _check _result _cb ( callback ) ) ;
}
function ftruncate ( fs , context , fd , length , callback ) {
// NOTE: length is optional
callback = arguments [ arguments . length - 1 ] ;
length = length || 0 ;
var ofd = fs . openFiles [ fd ] ;
if ( ! ofd ) {
callback ( new Errors . EBADF ( ) ) ;
} else if ( ! _ ( ofd . flags ) . contains ( O _WRITE ) ) {
callback ( new Errors . EBADF ( 'descriptor does not permit writing' ) ) ;
} else {
ftruncate _file ( context , ofd , length , standard _check _result _cb ( callback ) ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
module . exports = {
ensureRootDirectory : ensure _root _directory ,
open : open ,
close : close ,
mknod : mknod ,
mkdir : mkdir ,
rmdir : rmdir ,
unlink : unlink ,
stat : stat ,
fstat : fstat ,
link : link ,
read : read ,
readFile : readFile ,
write : write ,
writeFile : writeFile ,
appendFile : appendFile ,
exists : exists ,
getxattr : getxattr ,
fgetxattr : fgetxattr ,
setxattr : setxattr ,
fsetxattr : fsetxattr ,
removexattr : removexattr ,
fremovexattr : fremovexattr ,
lseek : lseek ,
readdir : readdir ,
utimes : utimes ,
futimes : futimes ,
rename : rename ,
symlink : symlink ,
readlink : readlink ,
lstat : lstat ,
truncate : truncate ,
ftruncate : ftruncate
2014-05-27 18:44:30 +00:00
} ;
2018-06-28 17:35:20 +00:00
} , { "../../lib/nodash.js" : 13 , "../path.js" : 4 , "../constants.js" : 15 , "../encoding.js" : 37 , "../errors.js" : 5 , "../directory-entry.js" : 38 , "../open-file-description.js" : 39 , "../super-node.js" : 40 , "../node.js" : 41 , "../stats.js" : 42 , "../buffer.js" : 3 } ] , 6 : [ function ( require , module , exports ) {
var _ = require ( '../../lib/nodash.js' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var isNullPath = require ( '../path.js' ) . isNull ;
var nop = require ( '../shared.js' ) . nop ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var Constants = require ( '../constants.js' ) ;
var FILE _SYSTEM _NAME = Constants . FILE _SYSTEM _NAME ;
var FS _FORMAT = Constants . FS _FORMAT ;
var FS _READY = Constants . FS _READY ;
var FS _PENDING = Constants . FS _PENDING ;
var FS _ERROR = Constants . FS _ERROR ;
var FS _NODUPEIDCHECK = Constants . FS _NODUPEIDCHECK ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var providers = require ( '../providers/index.js' ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var Shell = require ( '../shell/shell.js' ) ;
var Intercom = require ( '../../lib/intercom.js' ) ;
var FSWatcher = require ( '../fs-watcher.js' ) ;
var Errors = require ( '../errors.js' ) ;
var defaultGuidFn = require ( '../shared.js' ) . guid ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var STDIN = Constants . STDIN ;
var STDOUT = Constants . STDOUT ;
var STDERR = Constants . STDERR ;
var FIRST _DESCRIPTOR = Constants . FIRST _DESCRIPTOR ;
// The core fs operations live on impl
var impl = require ( './implementation.js' ) ;
// node.js supports a calling pattern that leaves off a callback.
function maybeCallback ( callback ) {
if ( typeof callback === "function" ) {
return callback ;
}
return function ( err ) {
if ( err ) {
throw err ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} ;
}
2014-05-27 18:44:30 +00:00
/ * *
2018-06-28 17:35:20 +00:00
* FileSystem
2014-05-27 18:44:30 +00:00
*
2018-06-28 17:35:20 +00:00
* A FileSystem takes an ` options ` object , which can specify a number of ,
* options . All options are optional , and include :
2014-05-27 18:44:30 +00:00
*
2018-06-28 17:35:20 +00:00
* name : the name of the file system , defaults to "local"
*
* flags : one or more flags to use when creating / opening the file system .
* For example : "FORMAT" will cause the file system to be formatted .
* No explicit flags are set by default .
*
* provider : an explicit storage provider to use for the file
* system ' s database context provider . A number of context
* providers are included ( see / src / providers ) , and users
* can write one of their own and pass it in to be used .
* By default an IndexedDB provider is used .
*
* guid : a function for generating unique IDs for nodes in the filesystem .
* Use this to override the built - in UUID generation . ( Used mainly for tests ) .
*
* callback : a callback function to be executed when the file system becomes
* ready for use . Depending on the context provider used , this might
* be right away , or could take some time . The callback should expect
* an ` error ` argument , which will be null if everything worked . Also
* users should check the file system ' s ` readyState ` and ` error `
* properties to make sure it is usable .
2014-05-27 18:44:30 +00:00
* /
2018-06-28 17:35:20 +00:00
function FileSystem ( options , callback ) {
2014-05-27 18:44:30 +00:00
options = options || { } ;
2018-06-28 17:35:20 +00:00
callback = callback || nop ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var flags = options . flags ;
var guid = options . guid ? options . guid : defaultGuidFn ;
var provider = options . provider || new providers . Default ( options . name || FILE _SYSTEM _NAME ) ;
// If we're given a provider, match its name unless we get an explicit name
var name = options . name || provider . name ;
var forceFormatting = _ ( flags ) . contains ( FS _FORMAT ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
function getDirEntry ( name , callback ) {
name = Path . join ( pathname , name ) ;
fs . stat ( name , function ( error , stats ) {
if ( error ) {
callback ( error ) ;
return ;
}
2018-05-29 18:03:59 +00:00
var entry = stats ;
2014-05-27 18:44:30 +00:00
if ( options . recursive && stats . type === 'DIRECTORY' ) {
2018-05-29 18:03:59 +00:00
list ( Path . join ( pathname , entry . name ) , function ( error , items ) {
2014-05-27 18:44:30 +00:00
if ( error ) {
callback ( error ) ;
return ;
}
entry . contents = items ;
result . push ( entry ) ;
callback ( ) ;
} ) ;
} else {
result . push ( entry ) ;
callback ( ) ;
}
} ) ;
}
2018-06-28 17:35:20 +00:00
=== === =
var fs = this ;
fs . readyState = FS _PENDING ;
fs . name = name ;
fs . error = null ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
fs . stdin = STDIN ;
fs . stdout = STDOUT ;
fs . stderr = STDERR ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Safely expose the list of open files and file
// descriptor management functions
var openFiles = { } ;
var nextDescriptor = FIRST _DESCRIPTOR ;
Object . defineProperty ( this , "openFiles" , {
get : function get ( ) {
return openFiles ;
}
} ) ;
this . allocDescriptor = function ( openFileDescription ) {
var fd = nextDescriptor ++ ;
openFiles [ fd ] = openFileDescription ;
return fd ;
} ;
this . releaseDescriptor = function ( fd ) {
delete openFiles [ fd ] ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Safely expose the operation queue
var queue = [ ] ;
this . queueOrRun = function ( operation ) {
var error ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( FS _READY == fs . readyState ) {
operation . call ( fs ) ;
} else if ( FS _ERROR == fs . readyState ) {
error = new Errors . EFILESYSTEMERROR ( 'unknown error' ) ;
} else {
queue . push ( operation ) ;
}
return error ;
} ;
function runQueued ( ) {
queue . forEach ( function ( operation ) {
operation . call ( this ) ;
} . bind ( fs ) ) ;
queue = null ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
// We support the optional `options` arg from node, but ignore it
this . watch = function ( filename , options , listener ) {
if ( isNullPath ( filename ) ) {
throw new Error ( 'Path must be a string without null bytes.' ) ;
}
if ( typeof options === 'function' ) {
listener = options ;
options = { } ;
}
options = options || { } ;
listener = listener || nop ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var watcher = new FSWatcher ( ) ;
watcher . start ( filename , false , options . recursive ) ;
watcher . on ( 'change' , listener ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
return watcher ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Deal with various approaches to node ID creation
function wrappedGuidFn ( context ) {
return function ( callback ) {
// Skip the duplicate ID check if asked to
if ( _ ( flags ) . contains ( FS _NODUPEIDCHECK ) ) {
callback ( null , guid ( ) ) ;
return ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Otherwise (default) make sure this id is unused first
function guidWithCheck ( callback ) {
var id = guid ( ) ;
context . getObject ( id , function ( err , value ) {
if ( err ) {
callback ( err ) ;
2014-05-27 18:44:30 +00:00
return ;
}
2018-06-28 17:35:20 +00:00
// If this id is unused, use it, otherwise find another
if ( ! value ) {
callback ( null , id ) ;
} else {
guidWithCheck ( callback ) ;
}
2014-05-27 18:44:30 +00:00
} ) ;
2018-06-28 17:35:20 +00:00
}
guidWithCheck ( callback ) ;
} ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
// Let other instances (in this or other windows) know about
// any changes to this fs instance.
function broadcastChanges ( changes ) {
if ( ! changes . length ) {
return ;
}
var intercom = Intercom . getInstance ( ) ;
changes . forEach ( function ( change ) {
intercom . emit ( change . event , change . path ) ;
} ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Open file system storage provider
provider . open ( function ( err ) {
function complete ( error ) {
function wrappedContext ( methodName ) {
var context = provider [ methodName ] ( ) ;
context . flags = flags ;
context . changes = [ ] ;
context . guid = wrappedGuidFn ( context ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// When the context is finished, let the fs deal with any change events
context . close = function ( ) {
var changes = context . changes ;
broadcastChanges ( changes ) ;
changes . length = 0 ;
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
return context ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
// Wrap the provider so we can extend the context with fs flags and
// an array of changes (e.g., watch event 'change' and 'rename' events
// for paths updated during the lifetime of the context). From this
// point forward we won't call open again, so it's safe to drop it.
fs . provider = {
openReadWriteContext : function openReadWriteContext ( ) {
return wrappedContext ( 'getReadWriteContext' ) ;
} ,
openReadOnlyContext : function openReadOnlyContext ( ) {
return wrappedContext ( 'getReadOnlyContext' ) ;
2014-05-27 18:44:30 +00:00
}
2018-06-28 17:35:20 +00:00
} ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
if ( error ) {
fs . readyState = FS _ERROR ;
} else {
fs . readyState = FS _READY ;
}
runQueued ( ) ;
callback ( error , fs ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-12-02 18:45:21 +00:00
/ * *
* Recursively walk a directory tree , reporting back all paths
* that were found along the way . The ` path ` must be a dir .
* Valid options include a ` regex ` for pattern matching paths
* and an ` exec ` function of the form ` function(path, next) ` where
* ` path ` is the current path that was found ( dir paths have an '/'
* appended ) and ` next ` is a callback to call when done processing
* the current path , passing any error object back as the first argument .
* ` find ` returns a flat array of absolute paths for all matching / found
* paths as the final argument to the callback .
* /
Shell . prototype . find = function ( path , options , callback ) {
var sh = this ;
var fs = sh . fs ;
if ( typeof options === 'function' ) {
callback = options ;
options = { } ;
}
options = options || { } ;
callback = callback || function ( ) { } ;
var exec = options . exec || function ( path , next ) { next ( ) ; } ;
var found = [ ] ;
if ( ! path ) {
callback ( new Errors . EINVAL ( 'Missing path argument' ) ) ;
return ;
}
function processPath ( path , callback ) {
exec ( path , function ( err ) {
if ( err ) {
callback ( err ) ;
return ;
}
found . push ( path ) ;
callback ( ) ;
} ) ;
}
function maybeProcessPath ( path , callback ) {
// Test the path against the user's regex, name, path primaries (if any)
// and remove any trailing slashes added previously.
var rawPath = Path . removeTrailing ( path ) ;
// Check entire path against provided regex, if any
if ( options . regex && ! options . regex . test ( rawPath ) ) {
callback ( ) ;
return ;
}
// Check basename for matches against name primary, if any
if ( options . name && ! minimatch ( Path . basename ( rawPath ) , options . name ) ) {
callback ( ) ;
return ;
}
// Check dirname for matches against path primary, if any
if ( options . path && ! minimatch ( Path . dirname ( rawPath ) , options . path ) ) {
callback ( ) ;
return ;
}
processPath ( path , callback ) ;
}
function walk ( path , callback ) {
path = Path . resolve ( sh . pwd ( ) , path ) ;
// The path is either a file or dir, and instead of doing
// a stat() to determine it first, we just try to readdir()
// and it will either work or not, and we handle the non-dir error.
fs . readdir ( path , function ( err , entries ) {
if ( err ) {
if ( err . code === 'ENOTDIR' /* file case, ignore error */ ) {
maybeProcessPath ( path , callback ) ;
} else {
callback ( err ) ;
}
return ;
}
// Path is really a dir, add a trailing / and report it found
maybeProcessPath ( Path . addTrailing ( path ) , function ( err ) {
if ( err ) {
callback ( err ) ;
return ;
}
entries = entries . map ( function ( entry ) {
return Path . join ( path , entry ) ;
} ) ;
async . eachSeries ( entries , walk , function ( err ) {
callback ( err , found ) ;
} ) ;
} ) ;
} ) ;
}
// Make sure we are starting with a dir path
fs . stat ( path , function ( err , stats ) {
if ( err ) {
callback ( err ) ;
return ;
}
if ( ! stats . isDirectory ( ) ) {
callback ( new Errors . ENOTDIR ( null , path ) ) ;
return ;
}
walk ( path , callback ) ;
} ) ;
} ;
2014-05-27 18:44:30 +00:00
module . exports = Shell ;
2015-06-29 16:29:46 +00:00
} , { "../../lib/async.js" : 1 , "../encoding.js" : 17 , "../errors.js" : 18 , "../path.js" : 25 , "./environment.js" : 31 , "minimatch" : 11 } ] , 33 : [ function ( require , module , exports ) {
var Constants = require ( './constants.js' ) ;
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2018-05-29 18:03:59 +00:00
var Path = require ( './path.js' ) ;
2014-05-27 18:44:30 +00:00
2018-05-29 18:03:59 +00:00
function Stats ( path , fileNode , devName ) {
2014-05-27 18:44:30 +00:00
this . dev = devName ;
2018-05-29 18:03:59 +00:00
this . node = fileNode . id ;
this . type = fileNode . type ;
2014-05-27 18:44:30 +00:00
this . size = fileNode . size ;
this . nlinks = fileNode . nlinks ;
this . atime = fileNode . atime ;
this . mtime = fileNode . mtime ;
this . ctime = fileNode . ctime ;
2018-05-29 18:03:59 +00:00
this . version = fileNode . version ;
this . mode = fileNode . mode ;
this . uid = fileNode . uid ;
this . gid = fileNode . gid ;
this . name = Path . basename ( path ) ;
2014-05-27 18:44:30 +00:00
}
Stats . prototype . isFile = function ( ) {
2018-05-29 18:03:59 +00:00
return this . type === Constants . NODE _TYPE _FILE ;
2014-05-27 18:44:30 +00:00
} ;
Stats . prototype . isDirectory = function ( ) {
2018-05-29 18:03:59 +00:00
return this . type === Constants . NODE _TYPE _DIRECTORY ;
2014-05-27 18:44:30 +00:00
} ;
Stats . prototype . isSymbolicLink = function ( ) {
2018-05-29 18:03:59 +00:00
return this . type === Constants . NODE _TYPE _SYMBOLIC _LINK ;
2014-05-27 18:44:30 +00:00
} ;
2018-06-28 17:35:20 +00:00
=== === =
=== === =
if ( err ) {
return complete ( err ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var context = provider . getReadWriteContext ( ) ;
context . guid = wrappedGuidFn ( context ) ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Mount the filesystem, formatting if necessary
if ( forceFormatting ) {
// Wipe the storage provider, then write root block
context . clear ( function ( err ) {
if ( err ) {
return complete ( err ) ;
}
impl . ensureRootDirectory ( context , complete ) ;
} ) ;
} else {
// Use existing (or create new) root and mount
impl . ensureRootDirectory ( context , complete ) ;
}
} ) ;
}
// Expose storage providers on FileSystem constructor
FileSystem . providers = providers ;
/ * *
* Public API for FileSystem
* /
[ 'open' , 'close' , 'mknod' , 'mkdir' , 'rmdir' , 'stat' , 'fstat' , 'link' , 'unlink' , 'read' , 'readFile' , 'write' , 'writeFile' , 'appendFile' , 'exists' , 'lseek' , 'readdir' , 'rename' , 'readlink' , 'symlink' , 'lstat' , 'truncate' , 'ftruncate' , 'utimes' , 'futimes' , 'setxattr' , 'getxattr' , 'fsetxattr' , 'fgetxattr' , 'removexattr' , 'fremovexattr' ] . forEach ( function ( methodName ) {
FileSystem . prototype [ methodName ] = function ( ) {
var fs = this ;
var args = Array . prototype . slice . call ( arguments , 0 ) ;
var lastArgIndex = args . length - 1 ;
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
// We may or may not get a callback, and since node.js supports
// fire-and-forget style fs operations, we have to dance a bit here.
var missingCallback = typeof args [ lastArgIndex ] !== 'function' ;
var callback = maybeCallback ( args [ lastArgIndex ] ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
var error = fs . queueOrRun ( function ( ) {
var context = fs . provider . openReadWriteContext ( ) ;
<< << << < HEAD
2018-05-29 18:03:59 +00:00
} , { "./constants.js" : 15 , "./path.js" : 25 } ] , 34 : [ function ( require , module , exports ) {
2018-06-28 17:35:20 +00:00
=== === =
<< << << < HEAD
} , { "./constants.js" : 15 } ] , 34 : [ function ( require , module , exports ) {
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2015-06-29 16:29:46 +00:00
var Constants = require ( './constants.js' ) ;
2018-06-28 17:35:20 +00:00
=== === =
// Fail early if the filesystem is in an error state (e.g.,
// provider failed to open.
if ( FS _ERROR === fs . readyState ) {
var err = new Errors . EFILESYSTEMERROR ( 'filesystem unavailable, operation canceled' ) ;
return callback . call ( fs , err ) ;
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
// Wrap the callback so we can explicitly close the context
function complete ( ) {
context . close ( ) ;
callback . apply ( fs , arguments ) ;
}
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2014-05-27 18:44:30 +00:00
this . id = Constants . SUPER _NODE _ID ;
2018-05-29 18:03:59 +00:00
this . type = Constants . NODE _TYPE _META ;
2014-07-14 20:01:52 +00:00
this . atime = options . atime || now ;
this . ctime = options . ctime || now ;
this . mtime = options . mtime || now ;
// root node id (randomly generated)
this . rnode = options . rnode ;
}
2018-06-28 17:35:20 +00:00
=== === =
// Either add or replace the callback with our wrapper complete()
if ( missingCallback ) {
args . push ( complete ) ;
} else {
args [ lastArgIndex ] = complete ;
}
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
2014-07-14 20:01:52 +00:00
2018-06-28 17:35:20 +00:00
// Forward this call to the impl's version, using the following
// call signature, with complete() as the callback/last-arg now:
// fn(fs, context, arg0, arg1, ... , complete);
var fnArgs = [ fs , context ] . concat ( args ) ;
impl [ methodName ] . apply ( null , fnArgs ) ;
} ) ;
if ( error ) {
callback ( error ) ;
2014-07-14 20:01:52 +00:00
}
2018-06-28 17:35:20 +00:00
} ;
} ) ;
2014-05-27 18:44:30 +00:00
2018-06-28 17:35:20 +00:00
FileSystem . prototype . Shell = function ( options ) {
return new Shell ( this , options ) ;
} ;
2014-07-14 20:01:52 +00:00
2018-06-28 17:35:20 +00:00
<< << << < HEAD
2015-06-29 16:29:46 +00:00
} , { "./constants.js" : 15 } ] } , { } , [ 22 ] ) ( 22 )
2018-05-29 18:03:59 +00:00
} ) ;
2018-06-28 17:35:20 +00:00
<< << << < HEAD
=== === =
=== === =
module . exports = FileSystem ;
} , { "../../lib/nodash.js" : 13 , "../path.js" : 4 , "../shared.js" : 14 , "../constants.js" : 15 , "../providers/index.js" : 18 , "../shell/shell.js" : 19 , "../../lib/intercom.js" : 16 , "../fs-watcher.js" : 17 , "../errors.js" : 5 , "./implementation.js" : 20 } ] , 1 : [ function ( require , module , exports ) {
module . exports = {
FileSystem : require ( './filesystem/interface.js' ) ,
Buffer : require ( './buffer.js' ) ,
Path : require ( './path.js' ) ,
Errors : require ( './errors.js' )
} ;
} , { "./filesystem/interface.js" : 6 , "./buffer.js" : 3 , "./path.js" : 4 , "./errors.js" : 5 } ] } , { } , [ 1 ] , "Filer" )
//# sourceMappingURL=/filer.map
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt
>>> >>> > Switch to parceljs for bundling , eslint for linting , drop grunt