@gotamedia/shapeshifter
TypeScript icon, indicating that this package has built-in type declarations

0.10.0 • Public • Published

Shapeshifter

Shapeshifter is a general format converter. It converts strings of one format (shape) into a string of another.

Installation

npm install @gotamedia/shapeshifter

Usage

API

const { OpenContentShapeProvider, ShapeBuilder } = require("@gotamedia/shapeshifter");

const shape = await new ShapeBuilder()
    .useShapeProvider(new OpenContentShapeProvider())
    .useInput(inputString)
    .build();

console.log(shape.shift());

That's it! You can use any number of shape providers or plug in your own. To enable all available shape providers you can use a shape provider resolver.

const { ShapeBuilder, ShapeProviderResolver } = require("@gotamedia/shapeshifter");

const shape = await new ShapeBuilder()
    .useShapeProviderResolver(new ShapeProviderResolver("/path/to/shape/providers/"))
    .useInput(inputString)
    .build();

console.log(shape.shift());

This saves you from updating the code anytime you want to use additional shape providers.

CLI

Shapeshifter also comes with a convenient CLI tool. You can use it to convert shapes in npm scripts or simply on the command line.

The shapeshifter command accepts input as stdin. This makes it easy to use with pipes. Here is a simple example using curl on the command line to fetch and convert an article from Open Content.

curl --silent --user [credentials] http://xlibris.oc.gota.infomaker.io:8080/opencontent/objects/[uuid] | shapeshifter

And here is an example of converting an article in a file.

shapeshifter < [path/to/article].xml

License

Shapeshifter is released under the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i @gotamedia/shapeshifter

Weekly Downloads

0

Version

0.10.0

License

MIT

Unpacked Size

63.7 kB

Total Files

33

Last publish

Collaborators

  • gotamedia-pu
  • diego-gota
  • nichelangelo