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

with

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

with

Compile time `with` for strict mode JavaScript

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
630K
decreased by-59.47%
Maintainers
1
Weekly downloads
 
Created
Source

with

Compile time with for strict mode JavaScript

build status Dependency Status NPM version

Installation

$ npm install with

Usage

var addWith = require('with')

addWith('obj', 'console.log(a)')
// => "var a = obj.a;console.log(a)"

addWith("obj || {}", "console.log(helper(a))", ["helper"])
// => var locals = (obj || {}),a = locals.a;console.log(helper(a))

API

addWith(obj, src, [exclude])

The idea is that this is roughly equivallent to:

with (obj) {
  src
}

There are a few differences though. For starters, it will be assumed that all variables used in src come from obj so any that don't (e.g. template helpers) need to have their names parsed to exclude as an array.

It also makes everything be declared, so you can always do:

if (foo === undefined)

instead of

if (typeof foo === 'undefined')

It is also safe to use in strict mode (unlike with) and it minifies properly (with disables virtually all minification).

License

MIT

FAQs

Package last updated on 31 May 2013

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