Cleans up after the CRUD instance. Should be called just before the
instance is deleted

@returns {Promise} A Promise that resolves when the instance is closed
974280
function close() {
    if (file !== false && options.listen) {
      fs.unwatch(file, listener);
    }

    return Promise.resolve();
  }
1274558
function() {
    return new Promise((resolve, reject) => {
      let instance;
      if (this.modelElement.name === this.node.getName()) {
        instance = this.node;
      } else {
        instance = this.mapper.getObject(this.modelElement.path());
      }

      if (instance) {
        if (instance.isStarted()) {
          instance.__update__(timesUp('update(...)', 30000, (err) => {
            if (err) {
              this.log.error('Unable to update ' + instance.getPath());
              reject(err);
            } else {
              this.log.debug(instance.getPath());
              this.node.kCore.emitter.emit('instanceUpdated', instance);
              resolve();
            }
          }));
        }
      } else {
        reject(new Error(this.toString() + ' error: unable to update instance ' + this.modelElement.name));
      }
    });
  }
1117221
function() {

        // TODO: should really use link to GeneratedFileNode.prototype.clean() here
        var _this = this;
        return QFS.remove(this.getPath())
            .then(function() {
                LOGGER.fverbose('[-] Removed %j', _this.getId());
            })
            .fail(function() {});

    }
912940
function cleanup (dirs) {
  return function (mode, pass, callback) {
    var done = after(dirs.length, callback)

    dirs.forEach(function (dir) {
      rimraf(dir, done)
    })
  }
}
1235633
function() {
        var that = this;
        return CRUD.EntityManager.getAdapter().Delete(that).then(function(result) {
            if (result.Action == 'deleted') {
                CRUD.log(that.getType() + ' ' + that.getID() + ' has been deleted! ');
                delete CRUD.EntityManager.cache[that.getType()][that.getID()];
                that.__values__[CRUD.EntityManager.getPrimary(that.getType())].ID = false;
            }
            return result;
        });
    }
839347
function cleanup() {
      res.removeListener('finish', makePoint);
      res.removeListener('error', cleanup);
      res.removeListener('close', cleanup);
    }
1315170
function customViewCleanup(db) {
    return new Promise(function (resolve, reject) {
      db._viewCleanup(function (err, res) {
        if (err) {
          return reject(err);
        }
        resolve(res);
      });
    });
  }
73565
function() {

    debug('shutting down...');

    var app = this;
    var server = this.server;

    if (!server) return Promise.resolve();

    return co.wrap(function* () {
      yield this.hookFor('shutdown');
    }).call(this).then(function() {
      server.close(function() { debug('goodbye!'); });
    });

  }
291657
public void cleanup ()
    {
        // tell any pending object subscribers that they're not getting their bits
        for (PendingRequest<?> req : _penders.values()) {
            for (Subscriber<?> sub : req.targets) {
                sub.requestFailed(req.oid, new ObjectAccessException("Client connection closed"));
            }
        }
        _penders.clear();
        _flusher.cancel();
        _flushes.clear();
        _dead.clear();
        _client.getRunQueue().postRunnable(new Runnable() {
            public void run () {
                _ocache.clear();
            }
        });
    }
1321846
function () {
    const oThis = this
      , promiseArray = [];

    return new Promise(async function (onResolve, onReject) {
      for (var chain in setupConfig.chains) {
        promiseArray.push(oThis._isRunning(chain));
      }
      return Promise.all(promiseArray).then(onResolve);
    });
  }
514331
function doDelete(filter) {
    console.log('doDelete', filter);
    return new Promise(function(resolve, reject) {
      var i, keysPromise, dataPromise;

      if (filter === true) {
        // Delete all
        if (options.cacheKeys) {
          keysPromise = Promise.resolve(cachedKeys);
        } else {
          keysPromise = readKeys();
        }

        keysPromise.then(function(existingKeys) {
          console.log('delete got existing keys', existingKeys);
          if (options.cacheValues) {
            cachedData = {};
          }
          if (options.cacheKeys) {
            cachedKeys = [];
          }

          saveData({}).then(function() {
            resolve(existingKeys);
          });
        }).catch(function(error) {
          reject(error);
        });

        return;
      } else if (common.keyTypes.indexOf(typeof filter) !== -1) {
        filter = [filter];
      } else if (filter instanceof Array) {
      } else if (typeof filter === 'object') {
        // Determine execution path for filter
        if (options.cacheValues) {
          dataPromise = Promise.resolve(cachedData);
        } else {
          dataPromise = readData();
        }

        dataPromise.then(function(data) {
          var deletedKeys = [];
          return common.processFilter(data, filter, function(id) {
            deletedKeys.push(id);
            delete data[id];
          }).then(function() {
            return saveData(data);
          }).then(function() {
            resolve(deletedKeys);
          });
        }).catch(function(error) {
          reject(error);
        });

        return;
      } else {
        reject({
          message: 'filter needs to be an object containing a filter'
        });
        return;
      }

      /* Check if we need to load the values key checking if the keys are
       *   actually in the database */
      if (!options.cacheValues && options.cacheKeys) {
        var haveKey = false;
        for (i in filter) {
          if(cachedKeys.indexOf(filter[i]) !== -1) {
            haveKey = true;
            break;
          }
        }
        if (haveKey) {
          dataPromise = readData();
        } else {
          resolve([]);
          return;
        }
      } else if (options.cacheValues) {
        dataPromise = Promise.resolve(cachedData);
      } else {
        dataPromise = readData();
      }

      dataPromise.then(function(data) {
        var deletedIds = [];
        // Go through and delete
        filter.forEach(function(id) {
          if (data[id] !== undefined) {
            delete data[id];
            deletedIds.push(id);
          }
        });

        return saveData(data).then(function() {
          resolve(deletedIds);
          return Promise.resolve();
        });
      }).catch(function(error) {
        reject(error);
      });
    });

  }
211266
function success() {
                self._ws.onclose = function () {
                    if (self._autoReconnect) {
                        var $promise = self.connect(true);
                        self.trigger("close", $promise);
                    } else {
                        self._cleanup();
                        self.trigger("close");
                    }
                };
                deferred.resolve();
            }
919395
function clean(done) {
	var del = require('del');
	del(cfg.destination).then(function () {
		if (typeof done === 'function') done();
		else process.exit();
	});
}
455823
function(instance) {
    var self = this;
    var result = Promise.bind();
    var fk = instance.getAttribute(this.foreignKeyAttr);
    if (fk) {
      result = result.then(function() {
        return self.objectsQuery(instance).execute();
      })
      .then(function(result) {
        self.validateFetchedObjects(instance, result);
        return result[0];
      });
    }
    else {
      result = result.then(function() {
        // pretend like we actually did the whole fetch & got back nothing
        self.associateFetchedObjects(instance, [null]);
      });
    }
    return result;
  }
841258
function() {
        return new Promise(function(resolve, reject) {
            exec("find . ! -name '" + __filename.split('/').pop() + "' -iname '*\.js' | xargs grep 'CRUD.Entity.call(this);' -isl", {
                timeout: 3000,
                cwd: process.cwd()
            }, function(err, stdout, stdin) {
                var results = stdout.trim().split('\n');
                var entities = {};

                // iterate all found js files and search for CRUD.define calls
                results.map(function(filename) {
                    if (filename.trim() == '') return;
                    var code = fs.readFileSync(filename) + '';
                    var ast = UglifyJS.parse(code);
                    ast.walk(new UglifyJS.TreeWalker(function(node) {
                        if (node instanceof UglifyJS.AST_Call && node.start.value == 'CRUD' && node.expression.property == 'define') {
                            entities[node.args[0].start.value] = filename;
                        }
                    }));
                });

                resolve(entities);
            });
        });
    }
549086
async function stop () {
    return new Promise(function (resolve, reject) {
        // if not server then resolve
        if (!immutableApp || !immutableApp.server || !immutableApp.started) {
            resolve()
        }
        // close server
        immutableApp.server.close(function (err) {
            if (err) {
                reject(err)
            }
            else {
                // clear server
                immutableApp.server = undefined
                immutableApp.started = false
                // resolve
                resolve()
            }
        })
    })
}
746742
function cleanup() {
    if (url) { URL.revokeObjectURL(url); }
    if (ww) { ww.terminate(); }
    if (timeout) { clearTimeout(timeout); }
  }