New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

presh

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

presh

An ex'presh'n langauge.. for safe evaluation of arbitrary functionality in javascript.

latest
Source
npmnpm
Version
3.0.3
Version published
Weekly downloads
704
8.64%
Maintainers
2
Weekly downloads
 
Created
Source

Presh

Node.js Test Runner GitHub code size in bytes GitHub package.json version GitHub

An ex'presh'n langauge.. for safe evaluation of arbitrary functionality in javascript.

Goals

Highly functional, stateless, easy to add scope to, expressive, readable.

Try

/example

features

Implicit returns.

halve(x){ x / 2 }

halve(2) -> 1

Constant-only assignment.

x = 5 <- Yep

x = 4 <- Nope!

a = { foo: 'bar' } <- Sure.

a.foo = 'baz' <- Nope!

var, let, const <- Nope nope nope!

namedFunction(x){ ... } <- Sure!

Ranges.

[1..10] -> [1,2,3,4,5,6,7,8,9,10]

[10..1] -> [10,9,8,7,6,5,4,3,2,1]

[-2..2] -> [-2,-1,0,1,2]

Spread (apply, array, object)

Apply:

sum(...args){ fold(args (a b) { a + b }) }

sum(1 2 3 4) -> 10

Array:

[0..10] -> [0,1,2,3,4,5,6,7,8,9,10]

Object:

defaults(){{a:1 b:2}}

{...defaults() c: 3} -> { a: 1, b: 2, c: 3 }

Literal delete:

Object:

defaults(){{a:1 b:2}}

{...defaults() c: 3 delete a} -> { b: 2, c: 3 }

usage

result = presh(expression, scope);

    var presh = require('presh');

    var result = presh('2 + thing', {
        thing: 4
    });

    if(result.error){
        // If the expression execution errored

        console.log(result.error);
    }else{
        // The expression executed without error.

        console.log(result.value);
    }

With cli

You can use the cli to run a script:

npm i -g presh
presh -e '1 + 1'

Syntax

presh syntax is similar to javascript, but a little more weighted to functional programming.

Key differences from javascript:

No commas required

Comma's are delimiters.

// Function definition
doSomething(1 2 3){
  ...
}

// Function call
doSomething(1 2 3)

// Array literal
[1 2 3]

Function Expression

    // Named
    add(parameter1 parameter2){ parameter1 + parameter2 }

    // Anonymous
    (parameter1 parameter2){ parameter1 + parameter2 }

Function Execution

    // From an identifier
    add(1 2) // -> 3

    // Anonymous
    ((x) {x+2}) (4) // -> 6

Range

    [0..100] // -> [0,1,2,3,...,98,99,100]

Looping

    map([0..100] (x){x*2})// -> [0,2,4,6,...,196,198,200]

FAQs

Package last updated on 17 Feb 2026

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