Skip to content

Commit

Permalink
feat: add wasm
Browse files Browse the repository at this point in the history
closes #18
  • Loading branch information
Boshen committed Jan 18, 2025
1 parent 415f18e commit e23da70
Show file tree
Hide file tree
Showing 10 changed files with 520 additions and 5 deletions.
173 changes: 173 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
[workspace]
resolver = "2"
members = [".", "wasm"]

[workspace.package]
edition = "2021"
license = "MIT"

[package]
name = "json-strip-comments"
edition.workspace = true
license.workspace = true
version = "1.0.4"
edition = "2021"
description = "Strip comments from JSON"
license = "MIT"
readme = "README.md"
repository = "https://github.com/oxc-project/json-strip-comments"

Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ pub fn strip(s: &mut str) -> Result<()> {
#[derive(Copy, Clone, Debug)]
pub struct CommentSettings {
/// True if c-style block comments (`/* ... */`) are allowed
block_comments: bool,
pub block_comments: bool,
/// True if c-style `//` line comments are allowed
slash_line_comments: bool,
pub slash_line_comments: bool,
/// True if shell-style `#` line comments are allowed
hash_line_comments: bool,
pub hash_line_comments: bool,
}

impl Default for CommentSettings {
Expand Down
1 change: 1 addition & 0 deletions wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
17 changes: 17 additions & 0 deletions wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "json-strip-comments-wasm"
version = "0.0.1"
edition.workspace = true
publish = false

[lib]
crate-type = ["cdylib", "rlib"]
test = false
doctest = false

[dependencies]
json-strip-comments = { path = ".." }
serde = { version = "1", features = ["derive"] }
serde-wasm-bindgen = "0.6.5"
tsify = "0.4.5"
wasm-bindgen = "0.2.99"
3 changes: 3 additions & 0 deletions wasm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# JSON Strip Comments

Strip json comments provided as a wasm file.
25 changes: 25 additions & 0 deletions wasm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "json-strip-comments",
"version": "1.0.4",
"license": "MIT",
"description": "Wasm for JSON Strip Comments (jsonc)",
"keywords": ["jsonc", "json", "strip", "comments"],
"repository": {
"type": "git",
"url": "https://github.com/oxc-project/json-strip-comments"
},
"main": "./json_strip_comments_wasm.js",
"types": "./json_strip_comments_wasm.d.ts",
"scripts": {
"build": "pnpm build-node && pnpm run copy-files",
"build-node": "wasm-pack build --release --target nodejs --out-dir ../npm",
"copy-files": "cp ./package.json ../npm/package.json && cp ./README.md ../npm/README.md",
"test": "node ./test/test.mjs"
},
"files": [
"json_strip_comments_wasm.d.ts",
"json_strip_comments_wasm.js",
"json_strip_comments_wasm_bg.wasm",
"json_strip_comments_wasm_bg.wasm.d.ts"
]
}
Loading

0 comments on commit e23da70

Please sign in to comment.