Socket
Socket
Sign inDemoInstall

monkey-punch

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    monkey-punch

Graceful Monkey-patching


Version published
Weekly downloads
5
increased by400%
Maintainers
1
Install size
59.6 kB
Created
Weekly downloads
 

Readme

Source

Graceful Monkey-patching.

UNDER HEAVY CONSTRUCTION

Monkey-patching is a way to override or extend the behaviour of a method without changing its original source code.

Override

var myMonkey = new Monkey({
  obj: patchTarget,
  method: 'sum',
  linesDelimiter: '\n',
  before: doItBefore,
  after: doItAfter,
  body: {
    regexps: {
      '/\)\n/g': addSemiQuoteFn, // add ';' after each ')'
      '/\{/g': ' ' // add space before each'{'
    },
    positions: {
      1: '// injection to line one',
      5: '// injection to line five',
      2: lineTwoInjectionFunc,
      '6,10': '// Injection to line 6 column 10',
      '2,3': lineTwoColumnThreeInjectionFunc
    }
  }
});


//...
myMonkey.restore();
// ...

References

Special thanks to Thai Pangsakulyanont and his article.

LICENSE

MIT: https://github.com/se-panfilov/monkey-punch/blob/master/LICENSE

Keywords

FAQs

Last updated on 03 Jun 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc