Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dqbd/tiktoken

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dqbd/tiktoken - npm Package Compare versions

Comparing version 1.0.0-alpha.4 to 1.0.0-alpha.5

10

package.json
{
"name": "@dqbd/tiktoken",
"version": "1.0.0-alpha.4",
"version": "1.0.0-alpha.5",
"description": "Javascript bindings for tiktoken",

@@ -22,6 +22,2 @@ "license": "MIT",

},
"./bundler": {
"types": "./tiktoken.d.ts",
"default": "./tiktoken.js"
},
"./init": {

@@ -46,6 +42,2 @@ "types": "./init.d.ts",

},
"./lite/bundler": {
"types": "./lite/tiktoken.d.ts",
"default": "./lite/tiktoken.js"
},
"./lite/init": {

@@ -52,0 +44,0 @@ "types": "./lite/init.d.ts",

@@ -138,69 +138,2 @@ # ⏳ tiktoken

#### Next.js 12
Using the older Next.js 12 version? Use the `@dqbd/tiktoken/bundler` or `@dqbd/tiktoken/lite/bundler` instead alongside the following `next.config.json` and `tsconfig.json` configurations:
```javascript
// next.config.json
const config = {
webpack(config, { isServer, dev }) {
config.experiments = {
asyncWebAssembly: true,
topLevelAwait: true,
layers: true,
};
return config;
},
};
```
```json
// tsconfig.json
{
"compilerOptions": {
"moduleResolution": "node16"
}
}
```
Usage in pages:
```typescript
import { get_encoding } from "@dqbd/tiktoken/bundler";
import { useState } from "react";
const encoding = get_encoding("cl100k_base");
export default function Home() {
const [input, setInput] = useState("hello world");
const tokens = encoding.encode(input);
return (
<div>
<input
type="text"
value={input}
onChange={(e) => setInput(e.target.value)}
/>
<div>{tokens.toString()}</div>
</div>
);
}
```
Usage in API routes:
```typescript
import type { NextApiRequest, NextApiResponse } from "next";
import { get_encoding } from "@dqbd/tiktoken/bundler";
export default function handler(req: NextApiRequest, res: NextApiResponse) {
const encoding = get_encoding("cl100k_base");
const tokens = encoding.encode("hello world");
encoding.free();
res.status(200).json({ tokens });
}
```
### [Vercel Edge Runtime](#vercel-edge-runtime)

@@ -207,0 +140,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc