Socket
Book a DemoInstallSign in
Socket

a-escss-estest

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

a-escss-estest

A passive, non-intrusive JavaScript runtime validator designed to achieve 100% function coverage.

2.1.5
unpublished
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

logo

What is ESCSS-ESTest?

A passive, non-intrusive JavaScript runtime validator designed to achieve 100% function coverage.

Features

  • 🪄 Supports TypeScript autocompletion.
  • 👌 Effortless integration with your codebase.
  • 📦 2 kB (minified + gzipped), zero dependencies.
  • 🎨 Designed with developer experience as a priority.
  • ⚙️ Unlock its full potential through E2E and unit testing.
  • 🚀 Optional runtime testing with minimal performance overhead.

Installation

  npm add escss-estest
  yarn add escss-estest
  pnpm add escss-estest
  bun add escss-estest

Core Concepts

Water filter

function demo() {
  // {...} is a filter
  {
    ESTest(...)
    ESTest(...)
  }

  // happy path
}

Core API

ESTest(input, type, publicMessage)

ESTest is just a console.error(...), so it won't break your app.

case 1
import { ESTest } from "escss-estest";

function sum(a, b) {
  {
    ESTest(a, "number");
    ESTest(b, "number");
  }

  return a + b;
}
case 2
import { ESTest } from "escss-estest";

async function getApi(a, b) {
  const apiData = await fetch("https://www.just-an-example.com/1");
  const data = await apiData.json();

  /**
   * data = {
   *    name: 'demo',
   *    age: 999,
   *    info: [
   *      {
   *        id: '1',
   *        city: 'foo',
   *        statusCode: 111
   *      },
   *      {
   *        id: '2',
   *        city: 'bar',
   *        statusCode: 222
   *      }
   *    ]
   * }
   */

  // You might get 'undefined' data. Use the optional chaining operator (?.) to prevent undefined from breaking your app.
  {
    ESTest(data.name, "string");
    ESTest(data.age, "number").min(0);
    ESTest(data.info[0]?.id, "string");
    ESTest(data.info[0]?.city, "string").regex(/(foo|bar)/);
    ESTest(data.info[0]?.statusCode, "number?");
  }

  return data;
}

unSafeESTest(input, type, errorMessage)

unSafeESTest throws a new Error, make sure to wrap it in try...catch

import { unSafeESTest } from "escss-estest";

app.post("/validate", async (req, res) => {
  try {
    const data = req.body;

    /**
     * data = {
     *    name: 'foo',
     *    email: 'abc12345@gmail.com'
     * }
     */

    {
      unSafeESTest(data.name, "string").min(3);
      unSafeESTest(data.email, "string", "invalid email").email();
    }

    res.json({ message: "Validation passed" });
  } catch (error) {
    res.status(400).json({ errors: error });
  }
});

Support API

globalThis.__ESCSS_ESTEST__.publicMessage

  • Get feedback from others
globalThis.__ESCSS_ESTEST__.publicMessage =
  "Please note when the issue occurred and send the details to [link].";

globalThis.__ESCSS_ESTEST__.isESTestDisabled

Why have this feature?

  • Designed to avoid vendor lock-in.
  • Optimized for production performance (if you want).

note: unSafeESTest WON'T be disabled (security reason)

globalThis.__ESCSS_ESTEST__.isESTestDisabled = true;

function sum(a, b) {
  {
    ESTest(a, "number");
    ESTest(b, "number");
  }

  return a + b;
}

// same as

function sum(a, b) {
  return a + b;
}

Keywords

JavaScript

FAQs

Package last updated on 25 May 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.