MCPcopy Create free account
hub / github.com/EOSIO/eosjs-api / normalize

Function normalize

bin/api-docs.js:6–32  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

4const camelCase = require('camel-case')
5
6function normalize(obj) {
7 if(typeof obj === 'string') {
8 obj = {type: obj, default: null, doc: ''}
9 } else {
10 // assert.equal(typeof obj, 'object')
11 if(obj.default == null) {
12 obj.default = null
13 }
14 if(obj.doc == null) {
15 obj.doc = ''
16 }
17 // if(obj.type === undefined) {
18 // obj.type = null
19 // }
20 }
21
22 obj.optional = /\?$/.test(obj.type) // ends in ?
23 if(obj.optional) {
24 obj.type = obj.type.substring(0, obj.type.length - 1) // remove ?
25 }
26 if(/\[\]$/.test(obj.type)) { // asset[]
27 obj.type = `Array<${obj.type.substring(0, obj.type.length - 2)}>`
28 } else {
29 obj.type = obj.type.replace('[', '<').replace(']', '>') //set<public_key>
30 }
31 return obj
32}
33
34function out(str = '') {
35 console.log(str.trim())

Callers 2

outJsDocFunction · 0.85
api-docs.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected