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

@boenfu/tsmonkey

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@boenfu/tsmonkey

```bash npm install @boenfu/tsmonkey ```

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

🐒 TSMonkey

npm install @boenfu/tsmonkey

Eval

import type { Eval } from '@boenfu/tsmonkey'

Eval<'4 + 8'> // 12
Eval<'2 * (4 + 8)'> // 24
Eval<'!99'> // false

Eval<'(3 + 2) * 5 == 25'> // true
Eval<'(3 > 2) != (2 > 3)'> // true

Eval<'7 && 9'> // 9
Eval<'false || 0'> // 0

variable declaration

Eval<`
let a = 2
let b = 3
let c = a * b
c * c
`> // 36

if else

Eval<`
let a = 2
let b = 3

if(a >= b) {
  return "a is greater than b"
} else {
  return "a is less than b"
}
`> // "a is less than b"

function

Eval<`
let a = 5
let b = 10

function foo(a, b) {
  return a - b
}

foo(b, a)
`> // 5

fibonacci

Eval<`
function fibonacci(n) {
  if (n < 2) { return 0 }
  if (n == 2) { return 1 }

  return fibonacci(n-1) + fibonacci(n - 2)
}

fibonacci(6)
`> // 5

Parser

import type { Parser } from '@boenfu/tsmonkey'
Parser<'let a = "如果你要写年"'>
// Program<[LetStatement<Identifier<"a">, StringLiteral<"如果你要写年">>]>

Lexer

import type { Lexer } from '@boenfu/tsmonkey'
Lexer<'let a = "如果你要写年"'>
// [
//   Token<TokenType.LET, "let">,
//   Token<TokenType.IDENT, "a">,
//   Token<TokenType.ASSIGN, "=">,
//   Token<TokenType.STRING, "如果你要写年">,
//   Token<TokenType.EOF, "">
// ]

FAQs

Package last updated on 03 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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