How to use the isBoolean function from lodash

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

3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
 * @category Objects
 * @param {*} value The value to check.
 * @returns {boolean} Returns `true` if the `value` is a boolean value, else `false`.
 * @example
 *
 * _.isBoolean(null);
 * // => false
 */
function isBoolean(value) {
  return value === true || value === false ||
fork icon73
star icon711
watch icon29

179
180
181
182
183
184
185
186
187
188
module.exports.isArray             = _.isArray;
module.exports.isArrayBuffer       = _.isArrayBuffer;
module.exports.isArrayLike         = _.isArrayLike;
module.exports.isArrayLikeObject   = _.isArrayLikeObject;
module.exports.isAssociative       = _.isAssociative;
module.exports.isBoolean           = _.isBoolean;
module.exports.isBuffer            = _.isBuffer;
module.exports.isDate              = _.isDate;
module.exports.isDecreasing        = _.isDecreasing;
module.exports.isElement           = _.isElement;
fork icon19
star icon122
watch icon0

+ 92 other calls in file

3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
    return func(value);
  };
}


function booleanToForm(value) {
  return lodash.isBoolean(value) ? value.toString() : value;
}


function booleanFromForm(value) {
  for (var _i = 0, _arr = [true, false]; _i < _arr.length; _i++) {
fork icon3
star icon15
watch icon0

+ 2 other calls in file

185
186
187
188
189
190
191
192
193
194
return Promise.allSettled(evaluateSubjects).then((results) =>
  results.forEach((r) => {
    if (r.status === "rejected") {
      throw new Error(r.reason);
    }
    this.#evaluation[r.value.id].evaluation = _.isBoolean(
      r.value.evaluation
    )
      ? r.value.evaluation
      : false;
fork icon1
star icon6
watch icon1

+ 4 other calls in file

404
405
406
407
408
409
410
411
412
413
414
415
416
console.log(isArrayLike); // => true


const isArrayLikeObject = _.isArrayLikeObject([1, 2, 3]);
console.log(isArrayLikeObject); // => true


const isBoolean = _.isBoolean(false);
console.log(isBoolean); // => true


const isBuffer = _.isBuffer(new Buffer(2));
console.log(isBuffer); // => true
fork icon0
star icon4
watch icon0

+ 15 other calls in file

588
589
590
591
592
593
594
595
596
case "focusMode":
  hasCorrectType =
    value &&
    _.isPlainObject(value) &&
    value.isOn &&
    _.isBoolean(value.isOn) &&
    _.isString(value.buttonLabel) &&
    (value.buttonAnchor === null || _.isString(value.buttonAnchor)) &&
    (value.buttonLink === null || _.isString(value.buttonLink));
fork icon0
star icon3
watch icon1

32
33
34
35
36
37
38
39
40
41
this.request = request;
this.api_key = api_key;
this.endpoint = options.endpoint || DefaultEndpoint;
this.proxy = options.proxy || null;
this.retry = _.isBoolean(options.retry) ? options.retry : true;
this.rate = _.isBoolean(options.rate) ? options.rate : true;

this.rate_limit = {};

// Create proxy methods
fork icon0
star icon1
watch icon0

55
56
57
58
59
60
61
62
63
64
}

// Payload
let payload = {
	request_object: request_object,
	retry: _.isBoolean(options.retry) ? options.retry : aftership.retry,
	raw: _.isBoolean(options.raw) ? options.raw : false
};

// Add retry count if needed
fork icon0
star icon1
watch icon0

85
86
87
88
89
90
91
92
93
94
lodash.each(table_data, function (row) {
    let hasMissingData = false;

    lodash.each(row, function (row_data) {
        if (
            lodash.isBoolean(row_data) &&
            row_data
        ) {
            hasMissingData = true;
        }
fork icon0
star icon1
watch icon0

313
314
315
316
317
318
319
320
321
322

var existingValueKeys = _.keys(params.ExpressionAttributeValues);

if (_.isObject(val) && _.isBoolean(val.Exists) && val.Exists === true) {
  operator = 'attribute_exists';
} else if (_.isObject(val) && _.isBoolean(val.Exists) && val.Exists === false) {
  operator = 'attribute_not_exists';
} else if (_.isObject(val) && _.has(val, '<>')) {
  operator = '<>';
  expectedValue = _.get(val, '<>');
fork icon0
star icon0
watch icon1

187
188
189
190
191
192
193
194
195
196
    return a === b;
}
if (_.isString(a)) {
    return _.isString(b) ? a === b : false;
} else if (_.isBoolean(a)) {
    return _.isBoolean(b) ? a === b : false;
} else if (_.isNumber(a)) {
    return _.isNumber(b) ? a === b : false;
} else if (Utils.isDefined(a.id)) {
    return a.id === b.id;
fork icon0
star icon0
watch icon2

62
63
64
65
66
67
68
69
70
71
function logger(index, defaultColorOrOptions, defaultSerializeAsOrAddAlways) {
  const defaultOptions = _.isPlainObject(defaultColorOrOptions) ? defaultColorOrOptions : {
    color: defaultColorOrOptions ?? "gray",
    serializeAs: defaultSerializeAsOrAddAlways ?? "yaml"
  };
  const addAlways = _.isBoolean(defaultSerializeAsOrAddAlways) ? defaultSerializeAsOrAddAlways : true;
  if (typeof index === "undefined") {
    logger("always").yellow("Warning: logger index is not set, this will not log anything. Set to 0 explicitly to remove this warning. Set to 'always' to always log.");
  }
  if (index && index !== "always" && index > loggerInfo.lastLogIndex) {
fork icon0
star icon0
watch icon1

127
128
129
130
131
132
133
134
135
136
 * @param {string} [errorMessage] the error message. If defined and the predicate is not fulfilled an error with the message will be thrown
 * @param {string|number|(string|number)[]} [messageArgs] values for placeholders in the errorMessage
 * @returns {boolean} the result of the predicate
 */
aBoolean(errorMessage, messageArgs) {
    let success = _.isBoolean(this.#contextValue);
    if (Debug.enabled) {
        this.#printDebug(this.aBoolean.name, success);
    }
    return this.#handleError(success, errorMessage, messageArgs);
fork icon0
star icon0
watch icon1

195
196
197
198
199
200
201
202
203
204
null: (arg) => _.isNull(arg),
string: (arg) => _.isString(arg),
emptyString: (arg) => arg === "",
number: (arg) => _.isNumber(arg),
zero: (arg) => arg === 0,
boolean: (arg) => _.isBoolean(arg),
false: (arg) => arg === false,
true: (arg) => arg === true,
function: (arg) => _.isFunction(arg),
object: (arg) => _.isObject(arg),
fork icon0
star icon0
watch icon1

+ 5 other calls in file

53
54
55
56
57
58
59
60
61
62
should.exist(jsonResponse.posts);
localUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(13);
localUtils.API.checkResponse(jsonResponse.posts[0], 'post');
localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);
_.isBoolean(jsonResponse.posts[0].email_only).should.eql(true);
jsonResponse.posts[0].email_only.should.eql(false);

// Ensure default order
fork icon0
star icon0
watch icon2

+ 35 other calls in file

28
29
30
31
32
33
34
35
36
37

this.client = options.client;
this.views = {}; //  map of ID -> view
this.formId = options.formId || 0;
this.mciViewFactory = new MCIViewFactory(this.client); //  :TODO: can this not be a singleton?
this.noInput = _.isBoolean(options.noInput) ? options.noInput : false;
this.actionKeyMap = {};

//
//  Small wrapper/proxy around handleAction() to ensure we do not allow
fork icon0
star icon0
watch icon1

95
96
97
98
99
100
101
102
103
104
},
toBeArrayOfObjects: (actual) => {
  return _.isArray(actual) && !actual.some((item) => !_.isObject(item));
},
toBeBoolean: (actual) => {
  return _.isBoolean(actual);
},
toBeEmptyArray: (actual) => {
  return _.isArray(actual) && actual.length === 0;
},
fork icon0
star icon0
watch icon0

332
333
334
335
336
337
338
339
340

opts.network = opts.network || 'livenet';
if (!_.contains(['livenet', 'testnet'], opts.network))
  return cb(new ClientError('Invalid network'));

opts.supportBIP44AndP2PKH = _.isBoolean(opts.supportBIP44AndP2PKH) ? opts.supportBIP44AndP2PKH : true;

var derivationStrategy = opts.supportBIP44AndP2PKH ? Constants.DERIVATION_STRATEGIES.BIP44 : Constants.DERIVATION_STRATEGIES.BIP45;
var addressType = (opts.n == 1 && opts.supportBIP44AndP2PKH) ? Constants.SCRIPT_TYPES.P2PKH : Constants.SCRIPT_TYPES.P2SH;
fork icon0
star icon0
watch icon0

+ 3 other calls in file

Other functions in lodash

Sorted by popularity

function icon

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