Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@heduapp/book-objects

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@heduapp/book-objects

## Gist Business objects, basically, copy the structure of XML. Specific elements will have its own implementation which calculates values from data. Hence, there should be zero redundancy of the data. There are codecs for different purposes (parsin

  • 0.22.0
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
3
Weekly downloads
 
Created
Source

Book Objects

Gist

Business objects, basically, copy the structure of XML.
Specific elements will have its own implementation which calculates values from data.
Hence, there should be zero redundancy of the data.
There are codecs for different purposes (parsing XML, saving business objects to DB or rendering using JSX).
If there is an error in a source (i.e. typo in the XML) it should be fixed by the codec.

Usage

Install

  • Configure SSH Config to access GitHub (SSH config sample).
  • Pick your version, from releases.
npm install git+ssh://ssh-config-name:HeduApp/book-objects.git#dist

Decode book XML into business objects

import * as BO from 'book-objects/business-object';
import XMLCodec from 'book-objects/codec/xml-codec';
const xmlCodec = new Codec.XMLCodec();
const book = (await xmlCodec.decode(bookXML)) as BO.Book;

Encode business objects into XML

import XMLCodec from 'book-objects/codec/xml-codec';
const xmlCodec = new XMLCodec();
const bookXML = await xmlCodec.encode(book);

Override component when encoding to JSX

import JSXCodec from 'book-objects/codec/jsx-codec';
import { BusinessObjectType } from 'book-objects/business-object';
import { ComponentOverrides } from 'book-objects/jsx';
import { CustomBook } from './CustomBook';
import { CDNImage } from './CDNImage';
const overrides: ComponentOverrides = {
    [BusinessObjectType.Book]: (book) => <CustomBook {...{book}} />,
    img: ({attributes: {src}}) => {
        const imageID = src as string;
        return (
            <CDNImage {...{imageID}} />
        );
    },
};
const jsxCodec = new JSXCodec(overrides);
const EncodedComponent = await jsxCodec.encode(bookObject);

Synchronous JSX encoding

import JSXCodec from 'book-objects/codec/jsx-codec';
const jsxCodec = new JSXCodec(overrides);
const EncodedComponent = jsxCodec.encodeSync(bookObject);

Contributing

Tests

Alsatian is used as a testing framework and test runner, Enzyme is used to test JSX.
To run tests:

npm run test
npm run test-watch

Code style

Code style is enforced by prettier
To prettify code:

npm run prettier
npm run prettier-watch

Before pushing to master

  • Are all tests passing?
  • Have you ran prettier?

Release new version

npm version major|minor|patch # Should be same as the version in the commit message
npm run release

FAQs

Package last updated on 03 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc