How to use the endsWith function from lodash

Find comprehensive JavaScript lodash.endsWith code examples handpicked from public code repositorys.

96
97
98
99
100
101
102
103
104
105
106


function findImageDescription (containerImage, containerImageDescriptions) {
  return _
    .chain(containerImageDescriptions)
    .find(({ image }) => {
      if (_.startsWith(image, '/') && _.endsWith(image, '/')) {
        image = image.substring(1, image.length - 1)
        return new RegExp(image).test(containerImage)
      }
      return image === containerImage
fork icon88
star icon199
watch icon22

+ 3 other calls in file

100
101
102
103
104
105
106
107
108
109
  _.filter(assets, function (asset) {
    return _.endsWith(asset.name, '.js');
  }).length +
  '个js文件,' +
  _.filter(assets, function (asset) {
    return _.endsWith(asset.name, '.map');
  }).length +
  '个map文件';
message = assets
  .map(function (asset) {
fork icon58
star icon132
watch icon11

+ 7 other calls in file

95
96
97
98
99
100
101
102
103
104
module.exports.dropRight           = _.dropRight;
module.exports.dropRightWhile      = _.dropRightWhile;
module.exports.dropWhile           = _.dropWhile;
module.exports.each                = _.each;
module.exports.eachRight           = _.eachRight;
module.exports.endsWith            = _.endsWith;
module.exports.enforce             = _.enforce;
module.exports.entries             = _.entries;
module.exports.entriesIn           = _.entriesIn;
module.exports.eq                  = _.eq;
fork icon19
star icon122
watch icon0

+ 92 other calls in file

793
794
795
796
797
798
799
800
801
802
803
804
805
console.log(capitalize); // => 'Fred'


const deburr = _.deburr('déjà vu');
console.log(deburr); // => 'deja vu'


const endsWith = _.endsWith('abc', 'c');
console.log(endsWith); // => true


const escape = _.escape('fred, barney, & pebbles');
console.log(escape); // => 'fred, barney, & pebbles'
fork icon0
star icon4
watch icon0

+ 15 other calls in file

76
77
78
79
80
81
82
83
84
85
86
87


if (argv.d) {
  dest = path.normalize(argv.d);
  var exists = fs.existsSync(dest);
  var isDir = exists && fs.statSync(dest).isDirectory();
  var fileRequested = _.endsWith(dest, '.js');


  if ((exists && isDir) || (!exists && !fileRequested)) {
    dest = path.join(dest, 'modernizr.js');
  }
fork icon1
star icon0
watch icon2

301
302
303
304
305
306
307
308
309
310
311
function loadPolicies() {
  const folder = `${process.cwd()}/src/api/policies`;
  const files = fs.readdirSync(folder);


  files
    .filter(file => _.endsWith(file, '.ts') || _.endsWith(file, '.js'))
    .forEach((file) => {
      // eslint-disable-next-line
      const func = require(`${folder}/${file}`);
      axel.policies[file.split('.')[0]] = func;
fork icon0
star icon3
watch icon1

41
42
43
44
45
46
47
48
49
50
51
52
  if (resolved === '/') return '/';


  // Remove the leading forward slash if present
  resolved = chopLeft(resolved, '/');
  // Add a trailing forward slash if missing
  return _.endsWith(resolved, '/') ? resolved : `${resolved}/`;
}


/**
 * Runs the provided async function and prints the error object (if any) to the console, it does NOT rethrow
fork icon0
star icon0
watch icon1

+ 3 other calls in file

53
54
55
56
57
58
59
60
61
62

let prefix = '/';
if (!_.isEmpty(trimmed)) {
  prefix = chopLeft(trimmed, '/');
  prefix = chopRight(prefix, '*');
  prefix = _.endsWith(prefix, '/') ? prefix : `${prefix}/`;
}

// eslint-disable-next-line consistent-return
return {
fork icon0
star icon0
watch icon1

+ 3 other calls in file

31
32
33
34
35
36
37
38
39
  pagePath = `${pagePath}`
}

// Enforce a trailing slash on all paths
const pathHasExtension = path.extname(pagePath) !== ''
const pathEndsWithSlash = _.endsWith(pagePath, '/')
if (!pathEndsWithSlash && !pathHasExtension) {
  pagePath = `${pagePath}/`
}
fork icon0
star icon0
watch icon1

+ 4 other calls in file

39
40
41
42
43
44
45
46
47
48
bundleStats.assets = _.filter(bundleStats.assets, function (asset) {
  // Removing query part from filename (yes, somebody uses it for some reason and Webpack supports it)
  // See #22
  asset.name = asset.name.replace(FILENAME_QUERY_REGEXP, '');

  return _.endsWith(asset.name, '.js') && !_.isEmpty(asset.chunks) && isAssetIncluded(asset.name);
});

// Trying to parse bundle assets and get real module sizes if `bundleDir` is provided
var bundlesSources = null;
fork icon0
star icon0
watch icon1

+ 4 other calls in file

119
120
121
122
123
124
125
126
127
128
// region configuration/index

noConfigurationSpecified() {
  return new DetoxConfigError({
    message: 'Cannot run Detox without a configuration file.',
    hint: _.endsWith(this.filepath, 'package.json')
      ? `Create an external .detoxrc.json configuration, or add "detox" configuration section to your package.json at:\n${this.filepath}`
      : 'Make sure to create external .detoxrc.json configuration in the working directory before you run Detox.'
  });
}
fork icon0
star icon0
watch icon0

Other functions in lodash

Sorted by popularity

function icon

lodash.get is the most popular function in lodash (7670 examples)