The modern build of lodash's _.keysIn as a module.
npx @tessl/cli install tessl/npm-lodash-keysin@3.0.0The modern build of lodash's _.keysIn as a module. This package provides a standalone implementation of lodash's keysIn utility function that creates an array of the own and inherited enumerable property names of an object.
npm install lodash.keysinvar keysIn = require('lodash.keysin');var keysIn = require('lodash.keysin');
// Basic object
var obj = { 'a': 1, 'b': 2 };
keysIn(obj);
// => ['a', 'b']
// Object with inherited properties
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
keysIn(new Foo);
// => ['a', 'b', 'c'] (iteration order is not guaranteed)
// Array-like objects
keysIn([1, 2, 3]);
// => ['0', '1', '2']
// Non-object values are coerced to objects
keysIn('hello');
// => ['0', '1', '2', '3', '4']Creates an array of the own and inherited enumerable property names of an object.
/**
* Creates an array of the own and inherited enumerable property names of `object`.
* Non-object values are coerced to objects.
*
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function keysIn(object);Parameters:
object (Object): The object to queryReturns:
Behavior:
Usage Examples:
var keysIn = require('lodash.keysin');
// Regular object
keysIn({ 'a': 1, 'b': 2 });
// => ['a', 'b']
// Object with prototype
function Shape() {
this.x = 0;
this.y = 0;
}
Shape.prototype.move = function(x, y) {
this.x += x;
this.y += y;
};
keysIn(new Shape);
// => ['x', 'y', 'move']
// Array
keysIn(['a', 'b', 'c']);
// => ['0', '1', '2']
// String (coerced to object)
keysIn('ab');
// => ['0', '1']
// Number (coerced to object)
keysIn(42);
// => []
// Null/undefined
keysIn(null);
// => []
keysIn(undefined);
// => []