Skip to content

Commit 38e0b2e

Browse files
committed
refactor(napi/parser): export functions directly
1 parent 407c95e commit 38e0b2e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

napi/parser/raw-transfer/common.mjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import {
77
import { BUFFER_ALIGN, BUFFER_SIZE, IS_TS_FLAG_POS } from '../generated/constants.mjs';
88
import { rawTransferSupported } from './supported.mjs';
99

10-
export { isJsAst, parseAsyncRawImpl, parseSyncRawImpl, prepareRaw, returnBufferToCache };
11-
1210
// Throw an error if running on a platform which raw transfer doesn't support.
1311
//
1412
// Note: This module is lazy-loaded only when user calls `parseSync` or `parseAsync` with
@@ -34,7 +32,7 @@ if (!rawTransferSupported()) {
3432
* @param {function} convert - Function to convert the buffer returned from Rust into a JS object
3533
* @returns {Object} - The return value of `convert`
3634
*/
37-
function parseSyncRawImpl(filename, sourceText, options, convert) {
35+
export function parseSyncRawImpl(filename, sourceText, options, convert) {
3836
const { buffer, sourceByteLen } = prepareRaw(sourceText);
3937
parseSyncRawBinding(filename, buffer, sourceByteLen, options);
4038
return convert(buffer, sourceText, sourceByteLen);
@@ -93,7 +91,7 @@ const queue = [];
9391
* @param {function} convert - Function to convert the buffer returned from Rust into a JS object
9492
* @returns {Object} - The return value of `convert`
9593
*/
96-
async function parseAsyncRawImpl(filename, sourceText, options, convert) {
94+
export async function parseAsyncRawImpl(filename, sourceText, options, convert) {
9795
// Wait for a free CPU core if all CPUs are currently busy.
9896
//
9997
// Note: `availableCores` is NOT decremented if have to wait in the queue first,
@@ -180,7 +178,7 @@ const textEncoder = new TextEncoder();
180178
* - `sourceByteLen`: Length of source text in UTF-8 bytes
181179
* (which may not be equal to `sourceText.length` if source contains non-ASCII characters).
182180
*/
183-
function prepareRaw(sourceText) {
181+
export function prepareRaw(sourceText) {
184182
// Cancel timeout for clearing buffers
185183
if (clearBuffersTimeout !== null) {
186184
clearTimeout(clearBuffersTimeout);
@@ -218,7 +216,7 @@ function prepareRaw(sourceText) {
218216
* @param {Uint8Array} buffer - Buffer containing AST in raw form
219217
* @returns {boolean} - `true` if AST is JS, `false` if TS
220218
*/
221-
function isJsAst(buffer) {
219+
export function isJsAst(buffer) {
222220
return buffer[IS_TS_FLAG_POS] === 0;
223221
}
224222

@@ -229,7 +227,7 @@ function isJsAst(buffer) {
229227
* @param {Uint8Array} buffer - Buffer
230228
* @returns {undefined}
231229
*/
232-
function returnBufferToCache(buffer) {
230+
export function returnBufferToCache(buffer) {
233231
buffers.push(buffer);
234232

235233
if (clearBuffersTimeout !== null) clearTimeout(clearBuffersTimeout);

0 commit comments

Comments
 (0)