How to use the include function from underscore.string

Find comprehensive JavaScript underscore.string.include code examples handpicked from public code repositorys.

294
295
296
297
298
299
300
301
302
303
if (w == "(!)") {
  a.push([[w], 0.0, 1.0, 1.0, 1, IRONY]);
}

// EMOTICONS: {("grin", +1.0): set((":-D", ":D"))}
// if ((!w.match(/^[0-9]+$/i)) && (w.length <= 5) && _str.include(PUNCTUATION, w)) {
  Object.keys(EMOTICONS).forEach(function (type) {
    if (_.contains(EMOTICONS[type].e, w.toLowerCase())) {
      a.push([[w], EMOTICONS[type].p, 1.0, 1.0, 1, MOOD]);
    }
fork icon7
star icon36
watch icon4

981
982
983
984
985
986
987
988
989
990
s.lstrip    = s.ltrim;
s.rstrip    = s.rtrim;
s.center    = s.lrpad;
s.rjust     = s.lpad;
s.ljust     = s.rpad;
s.contains  = s.include;
s.q         = s.quote;
s.toBool    = s.toBoolean;
s.camelcase = s.camelize;
s.mapChars  = s.map;
fork icon0
star icon6
watch icon0

717
718
719
720
721
722
723
724
725
726
t.equals( firstGridDotCount , 9, 'There are 9 dots representing 9 blank cells ' )
t.equals( firstGridEdgeCount , 6, 'There are 6 brackets representing 6 edges')

//gg.insertEnty(3, 'H')
console.log( grids[1] )
var secondGridHasHero = _s.include( grids[1], 'H')
var cellsBeforeHero = _s( grids[1] ).strLeft('H' ).count('.')
var cellsAfterHero = _s( grids[1] ).strRight('H' ).count('.')

t.ok(secondGridHasHero, 'Hero is in the grid')
fork icon0
star icon4
watch icon0

26
27
28
29
30
31
32
33
34
35

if (_.isEmpty(project)) {
  // See if we have a partial match with exactly one project.
  var projectNames = _.pluck(data2, 'name');
  var matchingProjects = _.filter(projectNames, function (value) {
    return _s.include(value, projectName);
  });

  console.log('Might mean: ');
  console.log(matchingProjects);
fork icon0
star icon1
watch icon0

68
69
70
71
72
73
74
75
76
77
  throw `Sorry, year undefined for ${JSON.stringify(r)}`;
}

if (!_.isUndefined(r.month)) {
  let mn = _.find(months, v => {
    return $.include(r.month.toLowerCase(), v.short);
  });
  if (!_.isUndefined(mn)) {
    r.month = mn.long;
  }
fork icon0
star icon0
watch icon2