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

solidity-comments

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solidity-comments - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

22

package.json
{
"name": "solidity-comments",
"version": "0.0.1",
"version": "0.0.2",
"repository": "github:frangio/solidity-comments",

@@ -55,13 +55,13 @@ "main": "index.js",

"optionalDependencies": {
"solidity-comments-darwin-arm64": "0.0.1",
"solidity-comments-win32-arm64-msvc": "0.0.1",
"solidity-comments-linux-arm64-gnu": "0.0.1",
"solidity-comments-linux-arm64-musl": "0.0.1",
"solidity-comments-win32-ia32-msvc": "0.0.1",
"solidity-comments-darwin-x64": "0.0.1",
"solidity-comments-win32-x64-msvc": "0.0.1",
"solidity-comments-linux-x64-gnu": "0.0.1",
"solidity-comments-linux-x64-musl": "0.0.1",
"solidity-comments-freebsd-x64": "0.0.1"
"solidity-comments-darwin-arm64": "0.0.2",
"solidity-comments-win32-arm64-msvc": "0.0.2",
"solidity-comments-linux-arm64-gnu": "0.0.2",
"solidity-comments-linux-arm64-musl": "0.0.2",
"solidity-comments-win32-ia32-msvc": "0.0.2",
"solidity-comments-darwin-x64": "0.0.2",
"solidity-comments-win32-x64-msvc": "0.0.2",
"solidity-comments-linux-x64-gnu": "0.0.2",
"solidity-comments-linux-x64-musl": "0.0.2",
"solidity-comments-freebsd-x64": "0.0.2"
}
}
# `solidity-comments`
`solidity-comments` is an N-API library built in Rust, which exposes a single function, which takes the contents of a Solidity source file and returns its imports and version pragmas.
`solidity-comments` is an N-API library built in Rust, which exposes a single function, which takes the contents of a Solidity source file and returns its comments.

@@ -15,30 +15,14 @@ ## Installation

export interface AnalysisResult {
versionPragmas: Array<string>;
imports: Array<string>;
comments: Array<Comment>;
}
export interface Comment {
start: number
end: number
text: string
}
export function analyze(input: string): AnalysisResult;
```
## Example
```ts
analyze(`
pragma solidity ^0.8.0;
import "./file.sol";
`);
// { versionPragmas: [ '^0.8.0' ], imports: [ './file.sol' ] }
```
## Goals
This library has two different goals:
1. Being fast
2. Being error-tolerant
Both are achieved by not parsing the Solidity source but just tokenizing it instead. This allows us to create a simple state machine that only recognizes imports and pragmas, ignoring everything else, and recovering from malformed tokens or expressions.
## Browser support

@@ -48,8 +32,2 @@

## Testing
This project has some JavaScript unit tests in `__test__`, and it's also tested using the entire [`smart-contract-sanctuary`](https://github.com/tintinweb/smart-contract-sanctuary).
You can find the scripts to test with the sanctuary in `test-with-sanctuary/`.
## Regenerating `index.js` and `index.d.ts`

@@ -56,0 +34,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