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

pst

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pst

Create mapping functions more easily

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

proxy-function-stack

proxy-function-stack (pst) is a library using ES Harmony proxies. It enables you to write functions such as mapping ones easier - no more verbose stuff like:

arr.map(function(item) {
  return item.foo().bar();
});

... but just:

arr.map( pst.foo().bar() );

Install

npm install pst

Requirements

Works with V8 3.8.8 (node 0.7.1). Make sure to run with the --harmony_proxies flag!

Usage

var pst = require("pst");

// now you can use it like in the example below

Example

Consider the following variables:

var arr = ["foo", "Bar", "some_123_thing"],

    rdigit = /\d/g,

    multiply = function(x) {
      return x * 3;
    };

Old

var mapped = arr.map(function(element) {
  return element.toUpperCase()
                .slice(0, -1)
                .replace(rdigit, multiply);
});

New

var mapped = arr.map( pst.toUpperCase()
                         .slice(0, -1)
                         .replace(rdigit, multiply) );

Result

["FO", "BA", "SOME_369_THIN"]

Keywords

proxies

FAQs

Package last updated on 13 Mar 2012

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