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

definitely

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

definitely - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

.travis.yml

8

package.json
{
"name": "definitely",
"version": "1.0.10",
"version": "1.0.11",
"description": "Disallow undefined property access in JavaScript",

@@ -8,3 +8,3 @@ "main": "definitely.js",

"build": "babel --minified -o definitely.js src/definitely.js",
"test": "mocha --harmony-proxies --reporter progress --compilers js:babel-core/register src/*.test.js",
"test": "mocha --reporter progress --compilers js:babel-core/register src/*.test.js",
"test:watch": "npm run test -- --watch",

@@ -32,2 +32,5 @@ "release": "xyz",

"homepage": "https://github.com/pelotom/definitely#readme",
"engines": {
"node": ">=6.0.0"
},
"devDependencies": {

@@ -37,3 +40,2 @@ "babel-cli": "6.14.0",

"chai": "^3.5.0",
"harmony-proxy": "^1.0.1",
"mocha": "^3.0.2",

@@ -40,0 +42,0 @@ "xyz": "^1.0.0"

@@ -1,7 +0,8 @@

# definitely
# definitely [![Build Status](https://travis-ci.org/pelotom/definitely.svg?branch=master)](https://travis-ci.org/pelotom/definitely)
Find `undefined` property bugs close to the source.
### Installation
```
$ npm install --save-dev definitely
```

@@ -37,3 +38,3 @@ ### Usage and rationale

The magic that enables this library is an ES2015 feature called [`Proxy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy), which allows intercepting arbitrary property access attempts and deciding what to do with them (in our case we throw an exception if the underlying object is missing the requisite property). `Proxy` is not yet supported in all browsers (e.g. IE and Safari) and in `Node` requires a special flag (`--harmony-proxies`) and [shim](https://www.npmjs.com/package/harmony-proxy). If `Proxy` is not found in the global scope, this library becomes a no-op.
The magic that enables this library is an ES2015 feature called [`Proxy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy), which allows intercepting arbitrary property access attempts and deciding what to do with them (in our case we throw an exception if the underlying object is missing the requisite property). `Proxy` is not yet supported in all browsers (e.g. IE and Safari) and in Node prior to version 6 requires a special flag (`--harmony-proxies`) and [shim](https://www.npmjs.com/package/harmony-proxy). If `Proxy` is not found in the global scope, this library becomes a no-op.

@@ -40,0 +41,0 @@ ### See also

@@ -19,3 +19,4 @@ export default (

const err = new Error(`attempted to access nonexistent property \`${key}\``)
err.stack = err.stack.replace(/(\n\s*at[^\n]*){2}/, '')
// Remove our stack frames from the trace leaving only client code
err.stack = err.stack.replace(/(\n[^\n]*definitely\/src\/definitely\.js[^\n]*)/g, '')
throw err

@@ -22,0 +23,0 @@ }

@@ -13,10 +13,2 @@ import { expect } from 'chai'

before(() => {
global.Proxy = require('harmony-proxy')
})
after(() => {
delete global.Proxy
})
it('allows valid property access', () => {

@@ -47,4 +39,10 @@ for (const key in obj)

it('is a noop', () => {
expect(definitely({}).meh).to.equal(undefined)
const Proxy = global.Proxy
delete global.Proxy
try {
expect(definitely({}).meh).to.equal(undefined)
} finally {
global.Proxy = Proxy
}
})
})
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