Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "pelias-model in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'pelias-model' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

module.exports.tests.sport_wildcard = function(test, common) {
  var doc = new Document('osm','a',1);
  doc.setMeta( 'tags', { 'sport': 'rugby_union' } );
  test('maps - sports inherit recreation via wildcard', function(t) {
    var stream = mapper( defaultMapping );
    stream.pipe( through.obj( function( doc, enc, next ){
      t.deepEqual(doc.category, ['recreation','entertainment'], 'correctly mapped');
      t.end(); // test will fail if not called (or called twice).
      next();
    }));
    stream.write(doc);
  });
};
test('errors - catch thrown errors', function(t) {
    var doc = new Document('a','b', 1);

    // this method will throw a generic Error for testing
    doc.getLayer = function(){ throw new Error('test'); };

    test_stream([doc], extractor(), function( err, actual ) {
      t.equal(actual.length, 0, 'no results');
      t.end();
    });
  });
test('errors - catch thrown errors', function(t) {
    var doc = new Document('osm','a',1);

    // this method will throw a generic Error for testing
    doc.getMeta = function(){ throw new Error('test'); };

    var stream = mapper();
    stream.pipe( through.obj( function( doc, enc, next ){
      t.deepEqual( doc.getLayer(), 'a', 'doc passthrough' );
      t.end(); // test will fail if not called (or called twice).
      next();
    }));
    stream.write(doc);
  });
};
module.exports.tests.international_airport = function(test, common) {
  var doc = new Document('a','venue',1);
  doc.setMeta('tags', { 'aerodrome': 'international', 'iata': 'JFK' });
  test('alias - international airport', function(t) {
    var stream = mapper();
    stream.pipe( through.obj( function( doc, enc, next ){
      t.deepEqual(doc.getPopularity(), 15000);
      t.end(); // test will fail if not called (or called twice).
      next();
    }));
    stream.write(doc);
  });
};
module.exports.tests.nonvenue = function (test, common) {
  var doc = new Document('osm', 'address', 1);
  doc.setMeta('tags', { 'importance': 'international' });
  test('does not map - non-venue', t => {
    var stream = mapper();
    stream.pipe(through.obj((doc, enc, next) => {
      t.false(doc.getPopularity(), 'no mapping performed');
      t.end(); // test will fail if not called (or called twice).
      next();
    }));
    stream.write(doc);
  });
};
const geojsonify = require('../../../helper/geojsonify');
const proxyquire = require('proxyquire').noCallThru();
const codec = require('pelias-model').codec;

module.exports.tests = {};

module.exports.tests.interface = function(test, common) {
  test('valid interface', function(t) {
    t.equal(typeof geojsonify, 'function', 'geojsonify is a function');
    t.equal(geojsonify.length, 2, 'accepts x arguments');
    t.end();
  });
};

// ensure null island coordinates work
// ref: https://github.com/pelias/pelias/issues/84
module.exports.tests.earth = function(test, common) {
  test('earth', function(t) {
    var earth = [{
docs.completeDoc = new Document('osm','venue','item:6');
docs.completeDoc.address_parts = {
  number: '13', street: 'Goldsmiths row', test: 'prop'
};
docs.completeDoc
  .setName('default','item6')
  .setName('alt','item six')
  .setCentroid({lat:6,lon:6})
  .setMeta('foo','bar')
  .setMeta('bing','bang');

docs.osmNode1 = new Document('osm','venue','item:7')
  .setName('node','node7')
  .setCentroid({lat:7,lon:7});

docs.osmWay1 = new Document('osm','venue','way:8')
  .setName('way','way8')
  .setMeta('nodes', [
    { lat: 10, lon: 10 },
    { lat: 06, lon: 10 },
    { lat: 06, lon: 06 },
    { lat: 10, lon: 06 }
  ]);

docs.osmRelation1 = new Document('osm','venue','item:9')
  .setName('relation','relation9')
  .setCentroid({lat:9,lon:9});

// ref: https://github.com/pelias/openstreetmap/issues/21
docs.semicolonStreetNumbers = new Document('osm','venue','item:10');
docs.semicolonStreetNumbers.setName('default','poi10');
docs.semicolonStreetNumbers.setCentroid({lat:10,lon:10});
stream.pipe( through.obj( function( doc, enc, next ){
      t.equal( Object.getPrototypeOf(doc), Document.prototype, 'correct proto' );
      t.equal( doc.getId(), 'X/1', 'correct id' );
      t.equal( doc.getLayer(), 'venue', 'defaults to venue' );
      t.end(); // test will fail if not called (or called twice).
      next();
    }));
    stream.write({ id: 1, type: 'X' });
function setupDocument(record, hierarchy) {
  var wofDoc = new Document( 'whosonfirst', record.place_type, record.id );

  if (record.name) {
    wofDoc.setName('default', record.name);

    // index a version of postcode which doesn't contain whitespace
    if (record.place_type === 'postalcode' && typeof record.name === 'string') {
      var sans_whitespace = record.name.replace(/\s/g, '');
      if (sans_whitespace !== record.name) {
        wofDoc.setNameAlias('default', sans_whitespace);
      }
    }

    // index name aliases for all other records (where available)
    else {
      if (record.name_aliases.length) {
        record.name_aliases.forEach(alias => {
function geojsonifyPlace(params, place) {
  const gid_components = decode_gid(place._id);
  // setup the base doc
  const doc = {
    id: gid_components.id,
    gid: new Document(place.source, place.layer, gid_components.id).getGid(),
    layer: place.layer,
    source: place.source,
    source_id: gid_components.id,
    bounding_box: place.bounding_box,
    lat: parseFloat(place.center_point.lat),
    lng: parseFloat(place.center_point.lon)
  };

  // assign name, logging a warning if it doesn't exist
  if (_.has(place, 'name.default')) {
    doc.name = field.getStringValue(place.name.default);
  } else {
    logger.warn(`doc ${doc.gid} does not contain name.default`);
  }

  // assign all the details info into the doc

Is your System Free of Underlying Vulnerabilities?
Find Out Now