Code Monkey home page Code Monkey logo

object-convert's Introduction

使用手冊

  1. Installation: npm i
  2. 使用 setJson 函數創造商店的物件,代入 config ,並將物件存入常數 shop 中,如 const shop = setJson(shopConfig);
  3. 此物件有 .init 方法,此方法為 Promise ,執行後可以抓 API 並重組 JSON,並 resolve 重組後的 JSON 出來,如下使用
const shopConfig = {
  shopId: 12345,
  domainName: 'http://example.com/'
};
const shop = setJson(shopConfig);
shop.init()
    .then(jsonAfterBuild => console.log('final JSON: ', JSON.stringify(jsonAfterBuild)))
    .catch(err => console.log(`oops! there is an error: ${err}`));

其他操作

  1. 取得全部的 API ,可使用 .getAPI() 方法
(function() {
  const shopConfig = {
    shopId: 12345,
    domainName: 'http://example.com/'
  };
  const shop = setJson(shopConfig);
  shop
    .getAPI()
    .then(jsonFromApi => console.log('get previous Json from API', jsonFromApi))
    .catch(err => console.log(`oops! there is an error: ${err}`));
})();
  1. 取得 Previous JSON 物件,也可在 .getAPI().init() 的 Promise 執行完後,用 .previousJson 取得。如 shop.previousJson
  2. 取得 Final JSON 物件,也可在 .init() 的 Promise 執行完後,用 .finalJson 取得。如 shop.finalJson

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.