Giter Site home page Giter Site logo

map-data's Introduction

map-data

Transform data, the easy way

Getting started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Node.js v12 or higher

Installing

The project is not published yet, so you will need to clone and install it using the command below.

npm install <folder>

Running the tests

There is a task called test, so a simple npm run test should be fine.

Usage

JSON

data-map doesn't care from where the data cames, so you are in charge of this task.

Imagine that you have this JSON:

{
    "id": 123,
    "title": "Introduction to map-data",
    "author": {
        "name": "John Doe",
        "birth": "1991-06-01"
    },
    "publishedAt": "2020-01-01"
}

You can extract a new JSON from it:

const mapData = require("map-data");

let expression = {
    name: "author.name"
};

let newJson = mapData(expression, data); // The data variable can come from wherever you want

Now your result variable will have this value:

{
    "name": "John Doe"
}

Other format

Not working with a JSON data source? Provide your own mapFn. Here is an example to work with cheerio.

const mapData = require("map-data");
const cheerio = require("cheerio");

let expression = {
    name: "li.author"
};

let config = {
    mapFn: (expr, data) => cheerio(expr, data); // This function will be called every time it needs to evaluate the property's expression
};

let newJson = mapData(expression, data, config);

Built Using

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgements

This project was inspired by:

map-data's People

Contributors

jvretamero avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.