or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/npm-lodash--keysin

The lodash method keysIn exported as a module for creating arrays of own and inherited enumerable property names.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/lodash.keysin@4.2.x

To install, run

npx @tessl/cli install tessl/npm-lodash--keysin@4.2.0

0

# Lodash KeysIn

1

2

The lodash method `_.keysIn` exported as a module that creates an array of the own and inherited enumerable property names of an object. This utility function is essential for deep object inspection and property enumeration across inheritance chains.

3

4

## Package Information

5

6

- **Package Name**: lodash.keysin

7

- **Package Type**: npm

8

- **Language**: JavaScript

9

- **Installation**: `npm install lodash.keysin`

10

11

## Core Imports

12

13

```javascript

14

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

15

```

16

17

ES6 modules:

18

19

```javascript

20

import keysIn from 'lodash.keysin';

21

```

22

23

## Basic Usage

24

25

```javascript

26

import keysIn from 'lodash.keysin';

27

28

// Simple object

29

keysIn({ 'a': 1, 'b': 2, 'c': 3 });

30

// => ['a', 'b', 'c']

31

32

// Object with inherited properties

33

function Foo() {

34

this.a = 1;

35

this.b = 2;

36

}

37

38

Foo.prototype.c = 3;

39

40

keysIn(new Foo);

41

// => ['a', 'b', 'c'] (iteration order is not guaranteed)

42

43

// Arrays

44

keysIn([1, 2, 3]);

45

// => ['0', '1', '2']

46

47

// Non-object values are coerced to objects

48

keysIn('hello');

49

// => ['0', '1', '2', '3', '4']

50

```

51

52

## Capabilities

53

54

### KeysIn Function

55

56

Creates an array of the own and inherited enumerable property names of object.

57

58

```javascript { .api }

59

/**

60

* Creates an array of the own and inherited enumerable property names of object.

61

* Non-object values are coerced to objects.

62

*

63

* @param {Object} object The object to query.

64

* @returns {Array} Returns the array of property names.

65

*/

66

function keysIn(object);

67

```

68

69

**Parameters:**

70

- `object` (`Object`): The object to query

71

72

**Returns:**

73

- (`Array`): Returns the array of property names

74

75

**Behavior:**

76

- Coerces non-object values to objects using `Object(object)`

77

- Iterates through all enumerable properties in the object and its prototype chain

78

- Filters out certain internal properties:

79

- 'constructor' property on prototypes when not explicitly set

80

- Array-like 'length' property in specific contexts to avoid duplicates with numeric indices

81

- Returns an array containing all qualifying property names

82

- Property iteration order is not guaranteed

83

84

**Usage Examples:**

85

86

```javascript

87

// Object with prototype chain

88

function Animal(name) {

89

this.name = name;

90

}

91

92

Animal.prototype.species = 'unknown';

93

Animal.prototype.speak = function() {};

94

95

const dog = new Animal('Rex');

96

dog.breed = 'German Shepherd';

97

98

keysIn(dog);

99

// => ['name', 'breed', 'species', 'speak']

100

101

// Array-like objects

102

const arrayLike = { 0: 'a', 1: 'b', length: 2 };

103

keysIn(arrayLike);

104

// => ['0', '1', 'length']

105

106

// Primitive values

107

keysIn(42);

108

// => []

109

110

keysIn('test');

111

// => ['0', '1', '2', '3']

112

113

keysIn(true);

114

// => []

115

```