コード例 #1
0
ファイル: locup.js プロジェクト: sackio/locup
  L.geocode = function(address, options, callback){
    var a = Belt.argulint(arguments);
    a.o = _.defaults(a.o, {
      'language': 'en'
    , 'key': L.settings.key
    });

    if (_.isObject(address)){
      a.o.components = address;
    } else {
      a.o.address = Belt._call(address, 'replace', /\s+/g, '+');
    }

    if (a.o.components) a.o.components = _.map(a.o.components, function(v, k){
      return k + ':' + v;
    }).join('|');

    if (a.o.bounds) a.o.bounds = Belt.toArray(a.o.bounds).join('|');

    return L._client.push({'request': {
      'uri': L.settings.url
    , 'qs': a.o
    , 'json': true
    }, 'callback': function(err, resp, body){
      if (err) return a.cb(err);
      if (Belt.get(body, 'status') !== 'OK') return a.cb(new Error(Belt.get(body, 'status') || 'Non-OK status occured'));
      return a.cb(null, Belt.deArray(Belt.get(body, 'results')));
    }});
  };
コード例 #2
0
ファイル: fstk.js プロジェクト: sackio/fstk
      , function(cb){
          if (a.o.skip_symlink) return cb();

          globals.stats.isSymbolicLink = Belt._call(globals, 'lstats.isSymbolicLink');
          if (globals.stats.isSymbolicLink) globals.stats.isFile = false;

          return cb();
        }
コード例 #3
0
ファイル: file_path.js プロジェクト: sackio/mongoo
  schema.method('unwatch_file', function(path){
    var self = this;

    if (!Belt._get(self.get(path), a.o.virtual_prefix + 'watcher')) return false;

    Belt._call(self.get(path)[a.o.virtual_prefix + 'watcher.watcher'], 'close');
    self.get(path)[a.o.virtual_prefix + 'watcher'] = null;

    return true;
  });
コード例 #4
0
ファイル: fstk.js プロジェクト: sackio/fstk
      , function(cb){
          _.extend(globals.stats, {
            'isFile': a.o.fast_stat ? undefined : Belt._call(globals, 'stats.isFile')
          , 'isDirectory': Belt._call(globals, 'stats.isDirectory')
          , 'isBlockDevice': a.o.fast_stat ? undefined : Belt._call(globals, 'stats.isBlockDevice')
          , 'isCharacterDevice': a.o.fast_stat ? undefined : Belt._call(globals, 'stats.isCharacterDevice')
          , 'isFIFO': a.o.fast_stat ? undefined : Belt._call(globals, 'stats.isFIFO')
          , 'isSocket': a.o.fast_stat ? undefined : Belt._call(globals, 'stats.isSocket')
          , 'isSymbolicLink': undefined
          , 'realpath': globals.realpath
          , 'path': globals.path
          });

          if (!a.o.skip_mime && globals.stats.isFile)
            globals.stats.mime = Mime.lookup(globals.stats.realpath);

          return cb();
        }
コード例 #5
0
ファイル: fstk.js プロジェクト: sackio/fstk
 F['replaceExt'] = function(path, ext){
   return Belt._call(path, 'replace', /\..*$/, '.' + ext);
 };