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

tsun

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsun - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

28

bin/src/repl.js

@@ -33,2 +33,3 @@ "use strict";

newLine: ts.NewLineKind.LineFeed,
noEmitHelpers: true,
experimentalDecorators: true

@@ -91,3 +92,3 @@ }); },

[/\b(let|yield|const|class|extends|interface|type)\b/, 'green'],
[/\b(try|catch|finally|Error|delete|throw|import)\b/, 'red'],
[/\b(try|catch|finally|Error|delete|throw|import|from|as)\b/, 'red'],
[/\b(eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent)\b/, 'yellow'],

@@ -97,2 +98,3 @@ [/\b(encodeURI|encodeURIComponent|escape|unescape|Object|Function|Boolean|Error)\b/, 'yellow'],

[/\b(console|module|process|require|arguments|fs|global)\b/, 'yellow'],
[/\b(private|public|protected|abstract|namespace|declare|@)\b/, 'magenta'],
];

@@ -374,3 +376,2 @@ while (line !== '') {

var allDiagnostics = service.getCompilerOptionsDiagnostics()
.concat(service.getSyntacticDiagnostics(DUMMY_FILE))
.concat(service.getSemanticDiagnostics(DUMMY_FILE));

@@ -433,9 +434,10 @@ return allDiagnostics.map(function (diagnostic) {

function replLoop(prompt, code) {
var fallback = codes;
var userInput = code;
versionCounter++;
code = buffer + '\n' + code;
var openCurly = (code.match(/\{/g) || []).length;
var closeCurly = (code.match(/\}/g) || []).length;
var openParen = (code.match(/\(/g) || []).length;
var closeParen = (code.match(/\)/g) || []).length;
var templateClosed = (code.match(/`/g) || []).length % 2 === 0;
if (openCurly === closeCurly && openParen === closeParen && templateClosed) {
codes += code;
var diagnostics = service.getSyntacticDiagnostics(DUMMY_FILE);
if (diagnostics.length === 0) {
codes = fallback;
startEvaluate(code);

@@ -445,4 +447,10 @@ repl(defaultPrompt);

else {
var indentLevel = openCurly - closeCurly + openParen - closeParen;
waitForMoreLines(code, indentLevel);
codes = fallback;
var openCurly = (code.match(/\{/g) || []).length;
var closeCurly = (code.match(/\}/g) || []).length;
var openParen = (code.match(/\(/g) || []).length;
var closeParen = (code.match(/\)/g) || []).length;
// at lease one indent in multiline
var indentLevel = (openCurly - closeCurly + openParen - closeParen) || 1;
waitForMoreLines(code, indentLevel || 1);
}

@@ -449,0 +457,0 @@ }

{
"name": "tsun",
"version": "0.2.0",
"version": "0.2.1",
"description": "TSUN: a repl for TypeScript Upgraded Node",

@@ -5,0 +5,0 @@ "bin": "./bin/tsun",

@@ -43,2 +43,3 @@ /// <reference path='../typings/node.d.ts' />

newLine: ts.NewLineKind.LineFeed,
noEmitHelpers: true,
experimentalDecorators: true

@@ -105,3 +106,3 @@ }),

[/\b(let|yield|const|class|extends|interface|type)\b/, 'green'],
[/\b(try|catch|finally|Error|delete|throw|import)\b/, 'red'],
[/\b(try|catch|finally|Error|delete|throw|import|from|as)\b/, 'red'],
[/\b(eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent)\b/, 'yellow'],

@@ -111,2 +112,3 @@ [/\b(encodeURI|encodeURIComponent|escape|unescape|Object|Function|Boolean|Error)\b/, 'yellow'],

[/\b(console|module|process|require|arguments|fs|global)\b/, 'yellow'],
[/\b(private|public|protected|abstract|namespace|declare|@)\b/, 'magenta'], // TS keyword
]

@@ -387,3 +389,2 @@ while (line !== '') {

let allDiagnostics = service.getCompilerOptionsDiagnostics()
.concat(service.getSyntacticDiagnostics(DUMMY_FILE))
.concat(service.getSemanticDiagnostics(DUMMY_FILE))

@@ -451,14 +452,21 @@

function replLoop(prompt: string, code: string) {
code = buffer + '\n' + code;
var openCurly = (code.match(/\{/g) || []).length;
var closeCurly = (code.match(/\}/g) || []).length;
var openParen = (code.match(/\(/g) || []).length;
var closeParen = (code.match(/\)/g) || []).length;
var templateClosed = (code.match(/`/g) || []).length % 2 === 0;
if (openCurly === closeCurly && openParen === closeParen && templateClosed) {
let fallback = codes
let userInput = code
versionCounter++
code = buffer + '\n' + code
codes += code
let diagnostics = service.getSyntacticDiagnostics(DUMMY_FILE)
if (diagnostics.length === 0) {
codes = fallback
startEvaluate(code)
repl(defaultPrompt)
} else {
let indentLevel = openCurly - closeCurly + openParen - closeParen;
waitForMoreLines(code, indentLevel)
codes = fallback
let openCurly = (code.match(/\{/g) || []).length;
let closeCurly = (code.match(/\}/g) || []).length;
let openParen = (code.match(/\(/g) || []).length;
let closeParen = (code.match(/\)/g) || []).length;
// at lease one indent in multiline
let indentLevel = (openCurly - closeCurly + openParen - closeParen) || 1
waitForMoreLines(code, indentLevel || 1)
}

@@ -465,0 +473,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