Tabnine Logo For Javascript
fn
Code IndexAdd Tabnine to your IDE (free)

How to use
fn
function
in
lodash

Best JavaScript code snippets using lodash.fn(Showing top 15 results out of 315)

origin: RisingStack/risingstack-bootcamp

function addPrefixAliasToColumns(tableName, columns) {
 const fn = fp.map((column) => `${tableName}.${column} as ${tableName}_${column}`)

 if (columns) {
  return fn(columns)
 }

 return fn
}
origin: RisingStack/risingstack-bootcamp

function getColumnsByTableNamePrefix(tableName, columns) {
 const fn = fp.compose([
  fp.mapKeys(fp.replace(`${tableName}_`, '')),
  fp.pickBy((value, key) => fp.startsWith(`${tableName}_`, key))
 ])

 if (columns) {
  return fn(columns)
 }

 return fn
}
origin: jonschlinkert/template-helpers

describe('lowercase', function() {
  it('should return an empty string when undefined.', function() {
   assert.equal(template('<%= lowercase() %>', imports)(), '');
  });
  it('should lower case the characters in a string.', function() {
   var fn = template('<%= lowercase("ABC") %>', imports);
   assert.equal(fn(), 'abc');
  });
 });
origin: jonschlinkert/template-helpers

describe('first', function() {
 it('should return an empty string when undefined.', function() {
  assert.equal(template('<%= first() %>', imports)(), '');
 });

 it('should return the first item in an array.', function() {
  var fn = template('<%= first(foo) %>', imports);
  assert.equal(fn({foo: ['a', 'b', 'c']}), 'a');
 });

 it('should return an array with the first two items in an array.', function() {
  var fn = template('<%= first(foo, 2) %>', imports);
  assert.deepEqual(fn({foo: ['a', 'b', 'c']}), ['a', 'b'].toString());
 });
});
origin: jonschlinkert/template-helpers

describe('after', function() {
 it('should return an empty string when undefined.', function() {
  assert.equal(template('<%= after() %>', imports)(), '');
 });

 it('should return all of the items in an array after the given index.', function() {
  var fn = template('<%= after(arr, 5) %>', imports);
  assert.deepEqual(fn(context), ['f', 'g', 'h'].toString());
 });
});
origin: jonschlinkert/template-helpers

describe('length', function() {
 it('should return an empty string when undefined.', function() {
  assert.equal(template('<%= length() %>', imports)(), '');
 });

 it('should return zero when the value is not an array.', function() {
  var fn = template('<%= length("foo") %>', imports);
  assert.equal(fn(context), '0');
 });

 it('should return the length of an array.', function() {
  var fn = template('<%= length(["b", "c", "a"]) %>', imports);
  assert.equal(fn(context), '3');
 });
});
origin: jonschlinkert/template-helpers

describe('unique', function() {
 it('should return an empty string when undefined.', function() {
  assert.equal(template('<%= unique() %>', imports)(), '');
 });
 it('should unique items from multiple arrays:', function() {
  var fn = template('<%= unique(["a", "b", "c", "c"]) %>', imports);
  assert.equal(fn(context), 'a,b,c');
 });
});
origin: jonschlinkert/template-helpers

describe('uppercase', function() {
  it('should return an empty string when undefined.', function() {
   assert.equal(template('<%= uppercase() %>', imports)(), '');
  });
  it('should upper case the characters in a string.', function() {
   var fn = template('<%= uppercase("abc") %>', imports);
   assert.equal(fn(), 'ABC');
  });
 });
origin: jonschlinkert/template-helpers

describe('compact', function() {
 it('should return an empty string when undefined.', function() {
  assert.equal(template('<%= compact() %>', imports)(), '');
 });

 it('should remove falsey values from an array.', function() {
  var fn = template('<%= compact([null, "a", undefined, 0, false, "b", "c", ""]) %>', imports);
  assert.equal(fn(context), 'a,b,c');
 });
});
origin: jonschlinkert/template-helpers

describe('before', function() {
 it('should return an empty string when undefined.', function() {
  assert.equal(template('<%= before() %>', imports)(), '');
 });
 it('should return all of the items in an array before the given index.', function() {
  var fn = template('<%= before(arr, 5) %>', imports);
  assert.deepEqual(fn(context), ['a', 'b', 'c'].toString());
 });
});
origin: jonschlinkert/template-helpers

describe('titlecase', function() {
  it('should return an empty string when undefined.', function() {
   assert.equal(template('<%= titlecase("foo") %>', imports)(), 'Foo');
  });
  it('should upper case the characters in a string.', function() {
   var fn = template('<%= titlecase("one two three") %>', imports);
   assert.equal(fn(), 'One Two Three');
  });
 });
origin: jonschlinkert/template-helpers

describe('join', function() {
 it('should return an empty string when undefined.', function() {
  assert.equal(template('<%= join() %>', imports)(), '');
 });

 it('should return all items in an array joined by the default separator.', function() {
  var fn = template('<%= join(arr) %>', imports);
  assert.equal(fn(context), 'a, b, c, d, e, f, g, h');
 });

 it('should return all items in an array joined by the given separator.', function() {
  var fn = template('<%= join(arr, " | ") %>', imports);
  assert.equal(fn(context), 'a | b | c | d | e | f | g | h');
 });
});
origin: jonschlinkert/template-helpers

describe('map', function() {
 it('should return an empty string when undefined.', function() {
  assert.equal(template('<%= map() %>', imports)(), '');
 });

 it('should map the items in the array and return new values.', function() {
  var o = {};
  o.double = function(str) {
   return str + str;
  };
  var fn = template('<%= map(["a","b","c"], double) %>', imports);
  assert.equal(fn(o), 'aa,bb,cc');
 });
});
origin: jonschlinkert/template-helpers

describe('union', function() {
 it('should return an empty string when undefined.', function() {
  assert.equal(template('<%= union() %>', imports)(), '');
 });

 it('should union items from multiple arrays:', function() {
  var fn = template('<%= union(["a", "c"], ["b", "b"]) %>', imports);
  assert.equal(fn(context), 'a,c,b');
 });

 it('should union items from multiple arrays:', function() {
  var fn = template('<%= union(["a"], ["b"]) %>', imports);
  assert.equal(fn(context), 'a,b');
 });
});
origin: jonschlinkert/template-helpers

describe('strip', function() {
  it('should return an empty string when undefined.', function() {
   assert.equal(template('<%= strip() %>', imports)(), '');
  });
  it('should strip the given substring from a string.', function() {
   var fn = template('<%= strip("foo", "foobar") %>', imports);
   assert.equal(fn(), 'bar');
  });
  it('should strip the given regex match from a string.', function() {
   var fn = template('<%= strip(/^foo/, "foobarfoo") %>', imports);
   assert.equal(fn(), 'barfoo');
  });
 });
lodash(npm)fn

Most used lodash functions

  • LoDashStatic.map
    Creates an array of values by running each element in collection through iteratee. The iteratee is
  • LoDashStatic.isEmpty
    Checks if value is empty. A value is considered empty unless it’s an arguments object, array, string
  • LoDashStatic.forEach
    Iterates over elements of collection invoking iteratee for each element. The iteratee is invoked wit
  • LoDashStatic.find
    Iterates over elements of collection, returning the first element predicate returns truthy for.
  • LoDashStatic.pick
    Creates an object composed of the picked `object` properties.
  • LoDashStatic.get,
  • LoDashStatic.isArray,
  • LoDashStatic.filter,
  • LoDashStatic.merge,
  • LoDashStatic.isString,
  • LoDashStatic.isFunction,
  • LoDashStatic.assign,
  • LoDashStatic.extend,
  • LoDashStatic.includes,
  • LoDashStatic.keys,
  • LoDashStatic.cloneDeep,
  • LoDashStatic.uniq,
  • LoDashStatic.isObject,
  • LoDashStatic.omit

Popular in JavaScript

  • crypto
  • qs
    A querystring parser that supports nesting and arrays, with a depth limit
  • request
    Simplified HTTP request client.
  • fs
  • fs-extra
    fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.
  • mongodb
    The official MongoDB driver for Node.js
  • aws-sdk
    AWS SDK for JavaScript
  • minimist
    parse argument options
  • lodash
    Lodash modular utilities.
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now