-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.mjs
26 lines (22 loc) · 897 Bytes
/
index.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { createRequire } from 'node:module';
const { platform, arch } = process
const require = createRequire(import.meta.url);
let nativeBinding = undefined
if (platform === 'win32' && arch === 'x64') {
nativeBinding = require('./dist/tiktoken-node.win32-x64-msvc.node')
} else if (platform === 'linux') {
if (arch === 'x64') {
nativeBinding = require('./dist/tiktoken-node.linux-x64-gnu.node')
} else if (arch === 'arm64') {
nativeBinding = require('./dist/tiktoken-node.linux-arm64-gnu.node')
}
} else if (platform === 'darwin') {
if (arch === 'x64') {
nativeBinding = require('./dist/tiktoken-node.darwin-x64.node')
} else if (arch === 'arm64') {
nativeBinding = require('./dist/tiktoken-node.darwin-arm64.node')
}
} else {
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
}
export default nativeBinding