Socket
Socket
Sign inDemoInstall

otrans

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

otrans

Object key transformation for Node.js.


Version published
Weekly downloads
4
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Otrans

Otrans Otrans Build Status Coverage Status License Dependency Status

Object key transformation for Node.js.

Installation

$ npm install --save -d otrans

Usage

const otrans = require("otrans");

.toCamel

otrans.toCamel({
    "glossary": {
        "title": "example glossary",
        "GlossDiv": {
            "title": "S",
            "GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
                    "SortAs": "SGML",
                    "GlossTerm": "Standard Generalized Markup Language",
                    "Acronym": "SGML",
                    "Abbrev": "ISO 8879:1986",
                    "GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
                        "GlossSeeAlso": [
                            "GML",
                            "XML"
                        ]
                    },
                    "GlossSee": "markup"
                }
            }
        }
    }
});

// {
//     "glossary": {
//         "title": "example glossary",
//         "glossDiv": {
//             "title": "S",
//             "glossList": {
//                 "glossEntry": {
//                     "id": "SGML",
//                     "sortAs": "SGML",
//                     "glossTerm": "Standard Generalized Markup Language",
//                     "acronym": "SGML",
//                     "abbrev": "ISO 8879:1986",
//                     "glossDef": {
//                         "para": "A meta-markup language, used to create markup languages such as DocBook.",
//                         "glossSeeAlso": [
//                             "GML",
//                             "XML"
//                         ]
//                     },
//                     "glossSee": "markup"
//                 }
//             }
//         }
//     }
// }

.toUnderscore

otrans.toUnderscore({
    "glossary": {
        "title": "example glossary",
        "GlossDiv": {
            "title": "S",
            "GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
                    "SortAs": "SGML",
                    "GlossTerm": "Standard Generalized Markup Language",
                    "Acronym": "SGML",
                    "Abbrev": "ISO 8879:1986",
                    "GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
                        "GlossSeeAlso": [
                            "GML",
                            "XML"
                        ]
                    },
                    "GlossSee": "markup"
                }
            }
        }
    }
});

// {
//     "glossary": {
//         "title": "example glossary",
//         "gloss_div": {
//             "title": "S",
//             "gloss_list": {
//                 "gloss_entry": {
//                     "id": "SGML",
//                     "sort_as": "SGML",
//                     "gloss_term": "Standard Generalized Markup Language",
//                     "acronym": "SGML",
//                     "abbrev": "ISO 8879:1986",
//                     "gloss_def": {
//                         "para": "A meta-markup language, used to create markup languages such as DocBook.",
//                         "gloss_see_also": [
//                             "GML",
//                             "XML"
//                         ]
//                     },
//                     "gloss_see": "markup"
//                 }
//             }
//         }
//     }
// }

Hint: The second parameter of toCamel or toUnderscore is a force transformation key map.

eg. if you're going to transform object like this:

otrans.toUnderscore({ jar2proxy: true, keepRunning: true });

You'll get { "jar_2_proxy": true, "keep_running": true }. But if you do like this:

otrans.toUnderscore({ jar2proxy: true, keepRunning: true }, { jar2proxy: proxy2jar });

You'll get { "proxy2jar": true, "keep_running": true } then.

Contribute

You're welcome to make pull requests!

「雖然我覺得不怎麼可能有人會關注我」

Keywords

FAQs

Package last updated on 08 Jun 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc