Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
parse-code-context
Advanced tools
Parse code context in a single line of javascript, for functions, variable declarations, methods, prototype properties, prototype methods etc.
Parse code context in a single line of javascript, for functions, variable declarations, methods, prototype properties, prototype methods etc.
Install with npm
$ npm i parse-code-context --save
var parse = require('parse-code-context');
parse("function app(a, b, c) {\n\n}");
Results in:
{ type: 'function statement',
name: 'app',
params: [ 'a', 'b', 'c' ],
string: 'app()',
original: 'function app() {\n\n}' }
parse("var app = function(a, b, c) {\n\n}");
Results in:
{ type: 'function expression',
name: 'app',
params: [ 'a', 'b', 'c' ],
string: 'app()',
original: 'var app = function() {\n\n}' }
module.exports
function expressionparse("module.exports = function foo(a, b, c) {\n\n}");
Results in:
{ type: 'function expression',
receiver: 'module.exports',
name: 'foo',
params: [ 'a', 'b', 'c' ],
string: 'module.exports()',
original: 'module.exports = function foo(a, b, c) {\n\n}' }
module.exports
methodparse("module.exports = function() {\n\n}");
Results in:
{ type: 'method',
receiver: 'module.exports',
name: '',
params: [],
string: 'module.exports.() {\n\n}()',
original: 'module.exports = function() {\n\n}' }
parse("Template.prototype.get = function() {}");
Results in:
{ type: 'prototype method',
class: 'Template',
name: 'get',
params: [],
string: 'Template.prototype.get()',
original: 'Template.prototype.get = function() {}' }
parse("Template.prototype.enabled = true;\nasdf");
Results in:
{ type: 'prototype property',
class: 'Template',
name: 'enabled',
value: 'true',
string: 'Template.prototype.enabled',
original: 'Template.prototype.enabled = true;\nasdf' }
parse("option.get = function() {}");
Results in:
{ type: 'method',
receiver: 'option',
name: 'get',
params: [],
string: 'option.get()',
original: 'option.get = function() {}' }
parse("option.name = \"delims\";\nasdf");
Results in:
{ type: 'property',
receiver: 'option',
name: 'name',
value: '"delims"',
string: 'option.name',
original: 'option.name = "delims";\nasdf' }
parse("var name = \"delims\";\nasdf");
Results in:
{ type: 'declaration',
name: 'name',
value: '"delims"',
string: 'name',
original: 'var name = "delims";\nasdf' }
parse("function app(a, b) {\n\n}");
Results in:
{ type: 'function statement',
name: 'app',
params: [ 'a', 'b' ],
string: 'app()',
original: 'function app(a, b) {\n\n}' }
parse("var app = function(foo, bar) {\n\n}");
Results in:
{ type: 'function expression',
name: 'app',
params: [ 'foo', 'bar' ],
string: 'app()',
original: 'var app = function(foo, bar) {\n\n}' }
parse("var app=function(foo,bar) {\n\n}");
Results in:
{ type: 'function expression',
name: 'app',
params: [ 'foo', 'bar' ],
string: 'app()',
original: 'var app=function(foo,bar) {\n\n}' }
parse("Template.prototype.get = function(key, value, options) {}");
Results in:
{ type: 'prototype method',
class: 'Template',
name: 'get',
params: [ 'key', 'value', 'options' ],
string: 'Template.prototype.get()',
original: 'Template.prototype.get = function(key, value, options) {}' }
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb on December 20, 2015.
FAQs
Fast and simple way to parse code context for use with documentation from code comments. Parses context from a single line of JavaScript, for functions, variable declarations, methods, prototype properties, prototype methods etc.
The npm package parse-code-context receives a total of 45,931 weekly downloads. As such, parse-code-context popularity was classified as popular.
We found that parse-code-context demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.