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

parse-function

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-function - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

.coveralls.yml

7

history.md
## v2.0.1 / February 9, 2015
- Release v2.0.1 / npm@v2.0.1
- remove `mocha-lcov-reporter`.. needless
- cov stuff
- fix tests for coverage
- faster travis and iojs + v0.12 support
## v2.0.0 / January 27, 2015

@@ -4,0 +11,0 @@ - Release v2.0.0 / npm@v2.0.0

9

package.json
{
"name": "parse-function",
"version": "2.0.0",
"version": "2.0.1",
"description": "Parse a given function or string (fn.toString()) to object with `name`, `params`, `parameters`, `args`, `arguments` and `body` properties.",

@@ -58,6 +58,7 @@ "scripts": {

"devDependencies": {
"cleanup-coverage-code": "^1.0.3",
"coverage-code-regex": "^1.0.2",
"istanbul-harmony": "^0.3.1",
"mocha": "*",
"mocha-lcov-reporter": "^0.0.1"
"mocha": "~2.1.0"
}
}
}

@@ -1,2 +0,2 @@

## [![npm][npmjs-img]][npmjs-url] [![mit license][license-img]][license-url] [![build status][travis-img]][travis-url] [![deps status][daviddm-img]][daviddm-url]
## [![npm][npmjs-img]][npmjs-url] [![mit license][license-img]][license-url] [![build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![deps status][daviddm-img]][daviddm-url]

@@ -6,4 +6,4 @@ > Parse a given function or string (fn.toString()) to object with `name`, `params`, `parameters`, `args`, `arguments` and `body` properties.

## Install
```bash
npm install parse-function
```
npm i --save parse-function
npm test

@@ -96,2 +96,2 @@ ```

_Powered and automated by [kdf](https://github.com/tunnckoCore), January 26, 2015_
_Powered and automated by [kdf](https://github.com/tunnckoCore), February 9, 2015_

@@ -12,3 +12,18 @@ /**

var parseFunction = require('./index');
var coverageCodeRegex = require('coverage-code-regex');
var cleanupCoverageCode = require('cleanup-coverage-code');
function hackExpected(expected) {
expected = expected.split('var').filter(Boolean);
expected = expected.map(function(val) {
return val.replace(/\s+/g,'');
}).map(function(val) {
return val.replace(/(function|return)(?:t|f)*?(?!\{)/g,'$1 ');
});
expected = expected.filter(Boolean).join('var ');
expected = 'var ' + expected;
return expected;
}
describe('parse-function:', function() {

@@ -32,2 +47,3 @@ it('should parse given string to object', function(done) {

it('should parse given function to object', function(done) {
/* istanbul ignore next */
var fixture = function yeah(cmd, params, cb) {

@@ -52,2 +68,11 @@ var fn = function beta() {};

// hack for coverage only
if (coverageCodeRegex().test(actual.body)) {
actual.parameters = actual.parameters.replace(/\s*/g, '');
expected.parameters = expected.parameters.replace(/\s*/g, '');
actual.body = cleanupCoverageCode(actual.body);
expected.body = hackExpected(expected.body);
}
assert.deepEqual(actual.args, expected.args);

@@ -62,2 +87,3 @@ assert.strictEqual(actual.name, expected.name);

it('should parse given anonymous function', function(done) {
/* istanbul ignore next */
var fixture = function(cmd, params, cb) {

@@ -82,2 +108,10 @@ var fn = function beta() {};

// hack for coverage only
if (coverageCodeRegex().test(actual.body)) {
actual.parameters = actual.parameters.replace(/\s*/g, '');
expected.parameters = expected.parameters.replace(/\s*/g, '');
actual.body = cleanupCoverageCode(actual.body);
expected.body = hackExpected(expected.body);
}
assert.deepEqual(actual.args, expected.args);

@@ -87,3 +121,3 @@ assert.strictEqual(actual.name, expected.name);

assert.deepEqual(actual.arguments, expected.arguments);
assert.strictEqual(actual.body, expected.body);
assert.strictEqual(cleanupCoverageCode(actual.body), expected.body);
done();

@@ -93,2 +127,3 @@ });

it('should have `.args` empty array and `.arguments` empty string', function(done) {
/* istanbul ignore next */
var fixture = function named() {

@@ -112,2 +147,10 @@ var obj = {

// hack for coverage only
if (coverageCodeRegex().test(actual.body)) {
actual.parameters = actual.parameters.replace(/\s*/g, '');
expected.parameters = expected.parameters.replace(/\s*/g, '');
actual.body = cleanupCoverageCode(actual.body);
expected.body = hackExpected(expected.body);
}
assert.deepEqual(actual.args, expected.args);

@@ -117,3 +160,3 @@ assert.strictEqual(actual.name, expected.name);

assert.deepEqual(actual.arguments, expected.arguments);
assert.strictEqual(actual.body, expected.body);
assert.strictEqual(cleanupCoverageCode(actual.body), expected.body);
done();

@@ -135,2 +178,7 @@ });

// hack for coverage only
if (coverageCodeRegex().test(actual.body)) {
actual.body = cleanupCoverageCode(actual.body);
}
assert.deepEqual(actual.args, expected.args);

@@ -137,0 +185,0 @@ assert.strictEqual(actual.name, expected.name);

Sorry, the diff of this file is not supported yet

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