or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

array.mdcollection.mddate.mdfunction.mdindex.mdlang.mdmath.mdnumber.mdobject.mdseq.mdstring.mdutil.md
tile.json

seq.mddocs/

0

# Sequence Functions

1

2

Chain operations that enable method chaining and lazy evaluation for complex data transformation pipelines.

3

4

## Capabilities

5

6

### Chain Operations

7

8

```javascript { .api }

9

/**

10

* Creates a lodash wrapper instance that enables lazy evaluation and method chaining

11

* @param {*} value - The value to wrap

12

* @returns {Object} Returns the new lodash wrapper instance

13

*/

14

function chain(value);

15

16

/**

17

* Executes the chain sequence to resolve the unwrapped value

18

* @returns {*} Returns the resolved unwrapped value

19

*/

20

function value();

21

22

/**

23

* Creates a clone of the chained sequence planting value as the wrapped value

24

* @param {*} value - The value to plant

25

* @returns {Object} Returns the new lodash wrapper instance

26

*/

27

function plant(value);

28

29

/**

30

* Enables the wrapper to be iterable

31

* @returns {Object} Returns the wrapper

32

*/

33

function toIterator();

34

```

35

36

## Usage Examples

37

38

```javascript

39

import { chain } from "lodash-es";

40

import _ from "lodash-es";

41

42

// Method chaining with explicit chain

43

const users = [

44

{ name: "Alice", age: 25, active: true },

45

{ name: "Bob", age: 30, active: false },

46

{ name: "Charlie", age: 35, active: true }

47

];

48

49

const result = chain(users)

50

.filter("active")

51

.map("name")

52

.sort()

53

.value();

54

// ["Alice", "Charlie"]

55

56

// Using lodash wrapper

57

const result2 = _(users)

58

.filter({ active: true })

59

.map("age")

60

.sum()

61

.value();

62

// 60

63

64

// Complex transformation chain

65

const data = [

66

{ category: "A", value: 10 },

67

{ category: "B", value: 20 },

68

{ category: "A", value: 30 },

69

{ category: "C", value: 15 }

70

];

71

72

const summary = chain(data)

73

.groupBy("category")

74

.mapValues(group => _.sumBy(group, "value"))

75

.toPairs()

76

.sortBy(1)

77

.reverse()

78

.value();

79

// [["A", 40], ["B", 20], ["C", 15]]

80

```