1.0.1 • Published 5 years ago

endecodify v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Kurasad#2521

Installation

Install using npm

npm install endecodify

Usage

Require the module

// CASE I
let endecodify = require(`endecodify`)
endecodify.startup() // Parameters: [References] A boolean to control if references to this module should be made under "process".
// Checking process.argv only happens when the startup function is called
// Startup return an object with the status of the module

// CASE II
let { startup } = require(`endecodify`)
startup()

// CASE III
require(`endecodify`).startup() // I recommend this :)

Examples

A few examples on the usage of this module

// CASE I
require(`endecodify`).startup()

console.log(process.encode(`Hello World!`)) // Returns:
/*

{
  case: 'success',
  code: '200',
  data: '8x10iA 8x05M 8x10iN ... +45 strings'
}

*/
console.log(process.decode(`8x10iU 8x07Q 8x10iF 8x09j 8x10iU 8x07w 8x10iU 8x22iW`)) // Returns: 
/* 

{
  case: 'success',
  code: '200',
  data: 'hi'
}

*/
// CASE II
let { startup, encode, decode } = require(`endecodify`)
startup(true) // Removes declarations under "process"

console.log(encode(`Hello World!`)) // Returns:
/*

{
  case: 'success',
  code: '200',
  data: '8x10iA 8x05M 8x10iN ... +45 strings'
}

*/

console.log(decode(`8x10iU 8x07Q 8x10iF 8x09j 8x10iU 8x07w 8x10iU 8x22iW`)) // Returns: 
/* 

{
  case: 'success',
  code: '200',
  data: 'hi'
}

*/
// CASE III
node . encode Hello World! // Returns [In Console]:
/*

{
  case: 'success',
  code: '200',
  data: '8x10iA 8x05M 8x10iN ... +45 strings'
}

*/
node . decode 8x10iU 8x07Q 8x10iF 8x09j 8x10iU 8x07w 8x10iU 8x22iW // Returns [In Console]:
/*

{
  case: 'success',
  code: '200',
  data: 'hi'
}

*/

Possible Error Situations

Some errors that can possibly occur

// CASE I
let { startup } = require(`endecodify`)
startup() // Returns { case: 'success', code: '200', message: 'Successfully setup' }
startup() // Returns throw new Error(`Setup function has already been called`)

// CASE II
let { startup, encode, decode } = require(`endecodify`)
encode("Hello World!") // Returns throw new Error(`Setup function has not been called`)

// CASE III
// Inputting unknown or broken values will throw an error defaulted by the process
1.0.1

5 years ago

1.0.0

5 years ago