Skip to content

Commit 72d6d72

Browse files
authored
Merge pull request #380 from pillarjs/v1-master-merge
chore: bring chage of master
2 parents dcc5822 + 9738c78 commit 72d6d72

File tree

10 files changed

+142
-158
lines changed

10 files changed

+142
-158
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424
name: Lint
2525
runs-on: ubuntu-latest
2626
steps:
27-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@v6
2828
with:
2929
persist-credentials: false
3030
- name: Setup Node.js
31-
uses: actions/setup-node@v4
31+
uses: actions/setup-node@v6
3232
with:
3333
node-version: 'lts/*'
3434

@@ -46,12 +46,12 @@ jobs:
4646
os: [ubuntu-latest, windows-latest, macos-latest]
4747
runs-on: ${{ matrix.os }}
4848
steps:
49-
- uses: actions/checkout@v4
49+
- uses: actions/checkout@v6
5050
with:
5151
persist-credentials: false
5252

5353
- name: Setup Node.js 22
54-
uses: actions/setup-node@v4
54+
uses: actions/setup-node@v6
5555
with:
5656
node-version: 22
5757

@@ -75,12 +75,12 @@ jobs:
7575

7676
runs-on: ${{ matrix.os }}
7777
steps:
78-
- uses: actions/checkout@v4
78+
- uses: actions/checkout@v6
7979
with:
8080
persist-credentials: false
8181

8282
- name: Setup Node.js ${{ matrix.node-version }}
83-
uses: actions/setup-node@v4
83+
uses: actions/setup-node@v6
8484
with:
8585
node-version: ${{ matrix.node-version }}
8686

@@ -110,7 +110,7 @@ jobs:
110110
run: npm run test:node-web
111111

112112
- name: Upload code coverage
113-
uses: actions/upload-artifact@v4
113+
uses: actions/upload-artifact@v6
114114
with:
115115
name: coverage-node-${{ matrix.node-version }}-${{ matrix.os }}
116116
path: ./coverage/lcov.info
@@ -123,14 +123,14 @@ jobs:
123123
contents: read
124124
checks: write
125125
steps:
126-
- uses: actions/checkout@v4
126+
- uses: actions/checkout@v6
127127

128128
- name: Install lcov
129129
shell: bash
130130
run: sudo apt-get -y install lcov
131131

132132
- name: Collect coverage reports
133-
uses: actions/download-artifact@v5
133+
uses: actions/download-artifact@v7
134134
with:
135135
path: ./coverage
136136
pattern: coverage-node-*
@@ -153,12 +153,12 @@ jobs:
153153

154154
runs-on: ubuntu-latest
155155
steps:
156-
- uses: actions/checkout@v4
156+
- uses: actions/checkout@v6
157157
with:
158158
persist-credentials: false
159159

160160
- name: Setup Node.js ${{ matrix.node-version }}
161-
uses: actions/setup-node@v4
161+
uses: actions/setup-node@v6
162162
with:
163163
node-version: ${{ matrix.node-version }}
164164

@@ -177,13 +177,13 @@ jobs:
177177
runs-on: 'ubuntu-latest'
178178

179179
steps:
180-
- uses: actions/checkout@v4
180+
- uses: actions/checkout@v6
181181
with:
182182
persist-credentials: false
183183

184-
- uses: actions/setup-node@v4
184+
- uses: actions/setup-node@v6
185185
with:
186-
node-version: 'lts/*'
186+
node-version: '22'
187187

188188
- name: Install
189189
run: |

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ jobs:
3939

4040
steps:
4141
- name: Checkout repository
42-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
42+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v4.2.2
4343
with:
4444
persist-credentials: false
4545

4646
# Initializes the CodeQL tools for scanning.
4747
- name: Initialize CodeQL
48-
uses: github/codeql-action/init@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8
48+
uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
4949
with:
5050
languages: ${{ matrix.language }}
5151
config: |
@@ -71,4 +71,4 @@ jobs:
7171
# ./location_of_script_within_repo/buildscript.sh
7272

7373
- name: Perform CodeQL Analysis
74-
uses: github/codeql-action/analyze@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # v3.29.8
74+
uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9

.npmignore

Lines changed: 0 additions & 14 deletions
This file was deleted.

Changelog.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
## Unreleased
1+
## 0.7.1
22

33
### 🚀 Improvements
44

5-
* types: improve type definitions and add missing APIs - by [@plbstl](https://github.com/plbstl) and [@bjohansebas](https://github.com/bjohansebas) and [@Phillip9587](https://github.com/Phillip9587)
5+
* types: improve type definitions and add missing APIs - by [@plbstl](https://github.com/plbstl) and [@bjohansebas](https://github.com/bjohansebas) in [#330](https://github.com/pillarjs/iconv-lite/pull/330)
66

77
## 0.7.0
88

9-
109
### 🐞 Bug fixes
1110

1211
* Handle split surrogate pairs when encoding utf8 - by [@yosion-p](https://github.com/yosion-p) and [@ashtuchkin](https://github.com/ashtuchkin) in [#282](https://github.com/ashtuchkin/iconv-lite/pull/282):

lib/index.d.ts

Lines changed: 63 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,30 @@
99
* This file provides detailed typings for the public API of iconv-lite
1010
*-------------------------------------------------------------------------------------------- */
1111

12+
import type Stream = require("stream")
1213
import type { Encoding } from "../types/encodings"
1314

14-
// --- Options ---
15-
1615
declare namespace iconv {
1716
export interface DecodeOptions {
18-
/** Strip the byte order mark (BOM) from the input, when decoding. @default true */
17+
/**
18+
* Strip the Byte Order Mark (BOM) from the input,
19+
* when decoding, if the codec is BOM-aware. @default true
20+
*/
1921
stripBOM?: boolean;
2022
/** Override the default endianness for `UTF-16` and `UTF-32` decodings. */
2123
defaultEncoding?: "utf16be" | "utf32be";
2224
}
2325

2426
export interface EncodeOptions {
25-
/** Add a byte order mark (BOM) to the output, when encoding. @default false */
27+
/**
28+
* Add a Byte Order Mark (BOM) to the output, when encoding,
29+
* if the codec is BOM-aware. @default false
30+
*/
2631
addBOM?: boolean;
2732
/** Override the default endianness for `UTF-32` encoding. */
2833
defaultEncoding?: "utf32be";
2934
}
3035

31-
// --- Return values ---
32-
3336
export interface EncoderStream {
3437
write(str: string): Buffer;
3538
end(): Buffer | undefined;
@@ -41,91 +44,80 @@ declare namespace iconv {
4144
}
4245

4346
export interface Codec {
44-
encoder: new (options?: EncodeOptions, codec?: any) => EncoderStream;
45-
decoder: new (options?: DecodeOptions, codec?: any) => DecoderStream;
47+
encoder: new (options?: EncodeOptions, codec?: Codec) => EncoderStream;
48+
decoder: new (options?: DecodeOptions, codec?: Codec) => DecoderStream;
49+
bomAware?: boolean;
4650
[key: string]: any;
4751
}
4852

49-
const iconv: {
50-
// --- Basic API ---
53+
/** Encodes a `string` into a `Buffer`, using the provided `encoding`. */
54+
export function encode (content: string, encoding: Encoding, options?: EncodeOptions): Buffer
5155

52-
/** Encodes a `string` into a `Buffer`, using the provided `encoding`. */
53-
encode(content: string, encoding: Encoding, options?: EncodeOptions): Buffer;
56+
/** Decodes a `Buffer` into a `string`, using the provided `encoding`. */
57+
export function decode (buffer: Buffer | Uint8Array, encoding: Encoding, options?: DecodeOptions): string
5458

55-
/** Decodes a `Buffer` into a `string`, using the provided `encoding`. */
56-
decode(buffer: Buffer | Uint8Array, encoding: Encoding, options?: DecodeOptions): string;
59+
/** Checks if a given encoding is supported by `iconv-lite`. */
60+
export function encodingExists (encoding: string): encoding is Encoding
5761

58-
/** Checks if a given encoding is supported by `iconv-lite`. */
59-
encodingExists(encoding: string): encoding is Encoding;
62+
/** Legacy alias for {@link iconv.encode}. */
63+
export const toEncoding: typeof iconv.encode
6064

61-
// --- Legacy aliases ---
65+
/** Legacy alias for {@link iconv.decode}. */
66+
export const fromEncoding: typeof iconv.decode
6267

63-
/** Legacy alias for {@link iconv.encode}. */
64-
toEncoding: typeof iconv.encode;
68+
/** Creates a stream that decodes binary data from a given `encoding` into strings. */
69+
export function decodeStream (encoding: Encoding, options?: DecodeOptions): NodeJS.ReadWriteStream
6570

66-
/** Legacy alias for {@link iconv.decode}. */
67-
fromEncoding: typeof iconv.decode;
71+
/** Creates a stream that encodes strings into binary data in a given `encoding`. */
72+
export function encodeStream (encoding: Encoding, options?: EncodeOptions): NodeJS.ReadWriteStream
6873

69-
// --- Stream API ---
74+
/**
75+
* Explicitly enable Streaming API in browser environments by passing in:
76+
* ```js
77+
* require('stream')
78+
* ```
79+
* @example iconv.enableStreamingAPI(require('stream'));
80+
*/
81+
export function enableStreamingAPI (stream_module: { Transform: typeof Stream.Transform }): void
7082

71-
/** Creates a stream that decodes binary data from a given `encoding` into strings. */
72-
decodeStream(encoding: Encoding, options?: DecodeOptions): NodeJS.ReadWriteStream;
83+
/** Creates and returns a low-level encoder stream. */
84+
export function getEncoder (encoding: Encoding, options?: EncodeOptions): EncoderStream
7385

74-
/** Creates a stream that encodes strings into binary data in a given `encoding`. */
75-
encodeStream(encoding: Encoding, options?: EncodeOptions): NodeJS.ReadWriteStream;
86+
/** Creates and returns a low-level decoder stream. */
87+
export function getDecoder (encoding: Encoding, options?: DecodeOptions): DecoderStream
7688

77-
/**
78-
* Explicitly enable Streaming API in browser environments by passing in:
79-
* ```js
80-
* require('stream')
81-
* ```
82-
* @example iconv.enableStreamingAPI(require('stream'));
83-
*/
84-
enableStreamingAPI(stream_module: any): void;
89+
/**
90+
* Returns a codec object for the given `encoding`.
91+
* @throws If the `encoding` is not recognized.
92+
*/
93+
export function getCodec (encoding: Encoding): Codec
8594

86-
// --- Low-level stream APIs ---
95+
/** Strips all non-alphanumeric characters and appended year from `encoding`. */
96+
export function _canonicalizeEncoding (encoding: Encoding): string
8797

88-
/** Creates and returns a low-level encoder stream. */
89-
getEncoder(encoding: Encoding, options?: EncodeOptions): EncoderStream;
98+
/** A cache of all loaded encoding definitions. */
99+
export let encodings: Record<
100+
Encoding,
101+
| string
102+
| {
103+
type: string;
104+
[key: string]: any;
105+
}
106+
> | null
90107

91-
/** Creates and returns a low-level decoder stream. */
92-
getDecoder(encoding: Encoding, options?: DecodeOptions): DecoderStream;
108+
/** A cache of initialized codec objects. */
109+
export let _codecDataCache: Record<string, Codec>
93110

94-
/**
95-
* Returns a codec object for the given `encoding`.
96-
* @throws If the `encoding` is not recognized.
97-
*/
98-
getCodec(encoding: Encoding): Codec;
99-
100-
/** Strips all non-alphanumeric characters and appended year from `encoding`. */
101-
_canonicalizeEncoding(encoding: Encoding): string;
102-
103-
// --- Properties ---
104-
105-
/** A cache of all loaded encoding definitions. */
106-
encodings: Record<
107-
Encoding,
108-
| string
109-
| {
110-
type: string;
111-
[key: string]: any;
112-
}
113-
> | null;
111+
/** The character used for untranslatable `Unicode` characters. @default "�" */
112+
export let defaultCharUnicode: string
114113

115-
/** A cache of initialized codec objects. */
116-
_codecDataCache: Record<string, Codec>;
114+
/** The character used for untranslatable `single-byte` characters. @default "?" */
115+
export let defaultCharSingleByte: string
117116

118-
/** The character used for untranslatable `Unicode` characters. @default "�" */
119-
defaultCharUnicode: string;
120-
121-
/** The character used for untranslatable `single-byte` characters. @default "?" */
122-
defaultCharSingleByte: string;
123-
124-
/** @readonly Whether or not, Streaming API is enabled. */
125-
readonly supportsStreams: boolean;
126-
}
117+
/** @readonly Whether or not, Streaming API is enabled. */
118+
export const supportsStreams: boolean
127119

128120
export type { iconv as Iconv, Encoding }
129-
export { iconv as default }
130121
}
122+
131123
export = iconv

0 commit comments

Comments
 (0)