Socket
Socket
Sign inDemoInstall

codon

Package Overview
Dependencies
2
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    codon

JavaScript Aide


Version published
Maintainers
1
Install size
2.00 MB
Created

Readme

Source

codon

JavaScript Code Assistant

Languages / 简体中文

Table of contents

Get Started

To format minified source code and offer the position in generated code if corresponding position in source code is provided.

const codon = require('codon');

let sourceCode = '// Minified JavaScript Source Code';

// -- return transformed position directly --
let output_1 = codon.format({ 
    code: sourceCode, 
    position: { line: 1, column: 10 },
});
// RETURN: { code, position }

// -- to do poisition transformation by yourself --
let output_2 = codon.format({ 
    code: sourceCode,
    position: true,
});
// RETURN: { code, positionFor }
let transformedPosition = output_2.positionFor({ line: 1, column: 10 });
// RETURN: { line, column }

If you wanna compress source code other than formatting it, use codon.compress() instead.

API

codon.compress()

The only parameter is an object with following attributes:

  • string | Buffer code
    Source code.

  • boolean | Object | [Object] position OPTIONAL
    As object (array), it represents the position in source code. As boolean and valued true, there SHOULD be an attribute named positionFor which is a function in charge of transforming position(s) in source code to position(s) in generated code.

E.g.

  • { string code } codon.format({ string code })
    To generate formatted code.

  • { string code, object position } codon.format({ string code, object position })
    To generate formatted code, and a transformed position object.

  • { string code, Array position } codon.format({ string code, Array position })
    To generate formatted code, and a group of transformed position objects.

  • { string code, function positionFor } codon.format({ string code, boolean position })
    To generate formatted code, and a transform method.

codon.format()

Similar to __codon.compress(), but to beautify source code other than minifying it.

Recommendations

Keywords

FAQs

Last updated on 13 Dec 2017

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