• XML to JSON - VSCode extension →

    Visual Studio Marketplace Visual Studio Marketplace Visual Studio Marketplace

    Convert XML from clipboard or current document/selection to JSON

    Are you using Code and working with XML builder tools day by day?

    XML to JSON can help you create the final object, just edit the variables that need dynamic data instead of typing each object key, attribute and no typos mistake. Converted data can be use for xmlbuilder or xml2js

    → Source
  • Property lookup on booleans →

    Performs a lot of dynamic lookups on the Boolean.prototype, as the ToBoolean operation let’s true pass for obj (which might itself be concerning that this can be a boolean). Instead of the coercion, the code should properly check for valid objects via typeof and strict equality with null comparison.

    Example:

    Use below

    if (typeof obj === "object" && obj !== null) {
        return obj[key] || 0
    }
    
    return 0
    

    Instead of

    return (obj && obj[key]) || 0
    
    → Source
  • pino-redis - first contribution

    Few months ago, I created a small project called pino-redis, a “transport” for the pino logger, receives pino logs from stdin and transform them into Redis.

    Yesterday, I decided add it into official transports documentation via PR #307. And now, it was there.

    It’s my first contribution to the open source community. You can find via npm or GitHub

  • Hello World! app with Node.js and Koa

    Install Node.js for your platform

    Open terminal and type

    mkdir hello-world; cd hello-world
    

    Initialize your project and link to npm

    Running this command initializes your project:

    npm init
    

    This creates a package.json file in your hello-world app folder and will prompt you to enter number of things. You can enter your way through all of them EXCEPT this one:

    entry point: (index.js)
    

    You will want to change this to

    <your_file_name>.js
    

    Install Koa in the hello-world directory

    npm i koa koa-router
    

    --save is default option in node v8

    Start your text editor and create a file named as entry point

    const Koa = require('koa')
    const Router = require('koa-router')
    
    const app = new Koa()
    const router = new Router()
    
    router.get('/', ctx => {
        ctx.status = 200
        ctx.body = 'Hello, World'
    })
    
    app.use(router.routes())
    
    app.listen(3000, () => {
        console.log('app listening on port 3000')
    })
    

    Run the app

    node <your_file_name>.js
    

    Cheers!