CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-lodash-keysin

The modern build of lodash's _.keysIn as a module.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

lodash.keysin

The 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.

Package Information

  • Package Name: lodash.keysin
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install lodash.keysin

Core Imports

var keysIn = require('lodash.keysin');

Basic Usage

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']

Capabilities

keysIn Function

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 query

Returns:

  • (Array): Returns the array of property names

Behavior:

  • Non-object values are coerced to objects
  • Returns empty array for null/undefined values
  • Handles array-like objects (arrays, arguments objects) by including numeric indices as strings
  • Includes inherited enumerable properties from the prototype chain
  • Excludes 'constructor' property when the object is a prototype or when constructor is not an own property
  • Iteration order is not guaranteed

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);
// => []
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/lodash.keysin@3.0.x
Publish Source
CLI
Badge
tessl/npm-lodash-keysin badge