Skip to content

Commit

Permalink
docs: correct jsdocs for genObjectFromRaw (resolves #97)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 16, 2024
1 parent 39505b5 commit 35c1a2f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ Generate an ESM `import type` statement.

Serialize an array to a string.

Values are not escaped or quoted.

**Example:**

```js
Expand All @@ -127,21 +129,27 @@ genArrayFromRaw([1, 2, 3])

Serialize an object to a string.

Values are not escaped or quoted.

**Example:**

```js
genObjectFromValues({ foo: "bar", test: '() => import("pkg")' })
genObjectFromRaw({ foo: "bar", test: '() => import("pkg")' })
// ~> `{ foo: bar, test: () => import("pkg") }`
```

### `genObjectFromRawEntries(array, indent, options)`

Serialize an array of key-value pairs to a string.

Values are not escaped or quoted.

### `genObjectFromValues(obj, indent, options)`

Serialize an object to a string.

Values are escaped and quoted if necessary.

**Example:**

```js
Expand Down
10 changes: 9 additions & 1 deletion src/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ export interface GenObjectOptions extends CodegenOptions {
/**
* Serialize an object to a string.
*
* Values are not escaped or quoted.
*
* @example
*
* ```js
* genObjectFromValues({ foo: "bar", test: '() => import("pkg")' })
* genObjectFromRaw({ foo: "bar", test: '() => import("pkg")' })
* // ~> `{ foo: bar, test: () => import("pkg") }`
* ```
*
Expand All @@ -28,6 +30,8 @@ export function genObjectFromRaw(
/**
* Serialize an object to a string.
*
* Values are escaped and quoted if necessary.
*
* @example
*
* ```js
Expand All @@ -48,6 +52,8 @@ export function genObjectFromValues(
/**
* Serialize an array to a string.
*
* Values are not escaped or quoted.
*
* @example
*
* ```js
Expand All @@ -73,6 +79,8 @@ export function genArrayFromRaw(
/**
* Serialize an array of key-value pairs to a string.
*
* Values are not escaped or quoted.
*
* @group serialization
*/
export function genObjectFromRawEntries(
Expand Down

0 comments on commit 35c1a2f

Please sign in to comment.