bootloader.js
function (target, cb) {
      if(!target) return cb(new Error('WebBoot.prune: size to clear must be provided'))
      var cleared = 0, remove = []
      
      function clear () {
        var n = remove.length
        while(remove.length) store.rm(remove.shift(), function () {
          if(--n) return
          if(cleared < target)
            cb(new Error('could not clear requested space'), cleared)
          else
            cb(null, cleared)
        })
      }

      store.ls(function (err, ls) {
        if(err) return cb(err)
        log.unfiltered(function (err, unfiltered) {
          if(err) return cb(err)
          var stored = unfiltered.reverse()
          ls.forEach(function (a) {
            if(!unfiltered.find(function (b) {
              return a.id == b.id
            })) {
              cleared += a.size
              remove.push(a.id)
            }
          })

          for(var i = 0; i < stored.length; i++) {
            var id = stored[i].value
            var item = ls.find(function (e) {
              return e.id === id
            })
            
            if(item) {
              cleared += item.size
              remove.push(id)
              if(cleared >= target) return clear()
            }
          }
          clear()
        })
      })
    }
function (target, cb) {
      if(!target) return cb(new Error('WebBoot.prune: size to clear must be provided'))
      var cleared = 0, remove = []
      
      function clear () {
        var n = remove.length
        while(remove.length) store.rm(remove.shift(), function () {
          if(--n) return
          if(cleared < target)
            cb(new Error('could not clear requested space'), cleared)
          else
            cb(null, cleared)
        })
      }

      store.ls(function (err, ls) {
        if(err) return cb(err)
        log.unfiltered(function (err, unfiltered) {
          if(err) return cb(err)
          var stored = unfiltered.reverse()
          ls.forEach(function (a) {
            if(!unfiltered.find(function (b) {
              return a.id == b.id
            })) {
              cleared += a.size
              remove.push(a.id)
            }
          })

          for(var i = 0; i < stored.length; i++) {
            var id = stored[i].value
            var item = ls.find(function (e) {
              return e.id === id
            })
            
            if(item) {
              cleared += item.size
              remove.push(id)
              if(cleared >= target) return clear()
            }
          }
          clear()
        })
      })
    }
function ( target , cb ) { if ( ! target ) return cb ( new Error ( 'WebBoot.prune: size to clear must be provided' ) ) var cleared = 0 , remove = [ ] function clear ( ) { var n = remove . length while ( remove . length ) store . rm ( remove . shift ( ) , function ( ) { if ( -- n ) return if ( cleared < target ) cb ( new Error ( 'could not clear requested space' ) , cleared ) else cb ( null , cleared ) } ) } store . ls ( function ( err , ls ) { if ( err ) return cb ( err ) log . unfiltered ( function ( err , unfiltered ) { if ( err ) return cb ( err ) var stored = unfiltered . reverse ( ) ls . forEach ( function ( a ) { if ( ! unfiltered . find ( function ( b ) { return a . id == b . id } ) ) { cleared += a . size remove . push ( a . id ) } } ) for ( var i = 0 ; i < stored . length ; i ++ ) { var id = stored [ i ] . value var item = ls . find ( function ( e ) { return e . id === id } ) if ( item ) { cleared += item . size remove . push ( id ) if ( cleared >= target ) return clear ( ) } } clear ( ) } ) } ) }
clear target amount of space.
clear target amount of space .