or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

async-generators.mdclass-system.mddecorators.mddestructuring.mdindex.mdmodule-interop.mdprivate-fields.mdtype-system.mdutilities.md

async-generators.mddocs/

0

# Async and Generator Helpers

1

2

Implementation of async/await syntax and generator functions for older JavaScript environments that don't support these features natively.

3

4

## Capabilities

5

6

### Async Function Helpers

7

8

#### _async_to_generator

9

10

Converts async functions to generator-based implementations for older environments.

11

12

```javascript { .api }

13

/**

14

* Converts async functions to generator-based implementations

15

* @param {Function} fn - The async function to convert

16

* @returns {Function} Function that returns a Promise

17

*/

18

function _async_to_generator(fn): Function;

19

```

20

21

**Usage Example:**

22

23

```javascript

24

const asyncFn = _async_to_generator(function* () {

25

const result = yield fetch('/api/data');

26

return result.json();

27

});

28

29

// Usage

30

asyncFn().then(data => console.log(data));

31

```

32

33

#### _await_value

34

35

Handles await expressions in transformed async functions.

36

37

```javascript { .api }

38

/**

39

* Handles await expressions in transformed async functions

40

* @param {any} value - Value to await

41

* @returns {any} The awaited value

42

*/

43

function _await_value(value): any;

44

```

45

46

### Async Generator Helpers

47

48

#### _async_generator

49

50

Creates async generator implementations.

51

52

```javascript { .api }

53

/**

54

* Creates async generator implementations

55

* @param {Function} fn - Generator function

56

* @returns {Object} Async generator object

57

*/

58

function _async_generator(fn): Object;

59

```

60

61

#### _async_generator_delegate

62

63

Handles yield* delegation in async generators.

64

65

```javascript { .api }

66

/**

67

* Handles yield* delegation in async generators

68

* @param {Object} inner - Inner iterator

69

* @param {Function} awaitWrap - Await wrapper function

70

* @returns {Object} Delegated async generator

71

*/

72

function _async_generator_delegate(inner, awaitWrap): Object;

73

```

74

75

#### _await_async_generator

76

77

Handles await operations in async generators.

78

79

```javascript { .api }

80

/**

81

* Handles await operations in async generators

82

* @param {any} value - Value to await

83

* @returns {Object} Awaited async generator value

84

*/

85

function _await_async_generator(value): Object;

86

```

87

88

#### _wrap_async_generator

89

90

Wraps async generator functions.

91

92

```javascript { .api }

93

/**

94

* Wraps async generator functions

95

* @param {Function} fn - Async generator function

96

* @returns {Function} Wrapped async generator

97

*/

98

function _wrap_async_generator(fn): Function;

99

```

100

101

### Iterator Helpers

102

103

#### _async_iterator

104

105

Creates async iterators from iterables.

106

107

```javascript { .api }

108

/**

109

* Creates async iterators from iterables

110

* @param {Iterable} iterable - Iterable to convert

111

* @returns {AsyncIterator} Async iterator

112

*/

113

function _async_iterator(iterable): AsyncIterator;

114

```

115

116

#### _create_for_of_iterator_helper_loose

117

118

Creates loose mode for-of iterator helpers.

119

120

```javascript { .api }

121

/**

122

* Creates loose mode for-of iterator helpers

123

* @param {Iterable} o - Iterable object

124

* @param {boolean} allowArrayLike - Allow array-like objects

125

* @returns {Object} Iterator helper

126

*/

127

function _create_for_of_iterator_helper_loose(o, allowArrayLike): Object;

128

```

129

130

### Generator Utilities

131

132

#### _skip_first_generator_next

133

134

Skips the first next() call on generators.

135

136

```javascript { .api }

137

/**

138

* Skips the first next() call on generators

139

* @param {Iterator} it - Generator iterator

140

* @returns {any} Generator result

141

*/

142

function _skip_first_generator_next(it): any;

143

```

144

145

#### _overload_yield

146

147

Handles yield expression overloading.

148

149

```javascript { .api }

150

/**

151

* Handles yield expression overloading

152

* @param {any} value - Value to yield

153

* @returns {any} Yielded value

154

*/

155

function _overload_yield(value): any;

156

```

157

158

### TypeScript Generator Helpers

159

160

#### _ts_generator

161

162

TypeScript-specific generator implementation (re-exported from tslib).

163

164

```javascript { .api }

165

/**

166

* TypeScript-specific generator implementation (re-exported from tslib.__generator)

167

* @param {Object} thisArg - This context

168

* @param {Function} body - Generator body function

169

* @returns {Object} TypeScript generator

170

*/

171

function _ts_generator(thisArg, body): Object;

172

```

173

174

#### _ts_values

175

176

TypeScript values iterator helper (re-exported from tslib).

177

178

```javascript { .api }

179

/**

180

* TypeScript values iterator helper (re-exported from tslib.__values)

181

* @param {any} o - Object to iterate

182

* @returns {Iterator} Values iterator

183

*/

184

function _ts_values(o): Iterator;

185

```