npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

akomando

v0.0.2

Published

Akomando is a document-centered library to handle Akoma Ntoso documents

Downloads

13

Readme

Akomando is a library to handle AkomaNtoso documents.

Plese refer to the official site for detailed documentation and a full list of available APIs.

Akomando is document-centered and can be run in node.js applications, browser applications and from command line.

Installation

Install akomando for node application###

To install akomando in your node application simply run the following:

npm install --save akomando

Install akomando for command line usage

To use akomando as a command line tool you must install it as a global npm package.

Firstly, install node by downloading it and following instructions at this page. Then run the following:

npm install -g akomando

Download and use akomando in browser application

Firstly, download either the bundle of akomando at this address.

Then, according to the version you have downloaded, insert one of the following scripts tag in your html:

<script src="./path/to/akomando/lib/bundle_v[x.x.x].akomando.js"></script>

Install akomando from CDN to use it in browser application

To use akomando by means of CDN, according to the version you want to use, just insert the following script tag in your html file:

<script src="https://www.akomando.io/code/bundle_v[x.x.x].akomando.js"
        integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
        crossorigin="anonymous"></script>

Usage

The followings are examples on how to import the library in your applications. For a full list of available APIs read the official site

In node

First import the akomando library as the followings:

In node (ES6)

import { createAkomando } from 'akomando';

In node (ES5)

var akomando = require('akomando');

Then, use akomando as the following examples:

const myAkomaNtosoStream = fs.readFileSync('./my-akomantoso.xml');
const myAkomaNtosoString = myAkomaNtosoStream.toString();

const myAkomando = createAkomando({
   aknString: myAkomaNtosoString,
});

// logs the doctype of the loaded document
console.log(myAkomando.getDocType());

// logs the loaded AkomaNtoso as XLM String
console.log(myAkomando.getAkomaNtoso({
   serialize: 'AKNString'
});

// logs the loaded AkomaNtoso as JSON
console.log(myAkomando.getAkomaNtoso({
   serialize: 'JSON'
}));

// logs the raw text of the loaded AkomaNtoso without new lines characters
console.log(myAkomando.getAkomaNtoso({
   serialize: 'TEXT',
   newLines: false,
}));

// logs the loaded AkomaNtoso as HTML String, without inserting the head element and the body element
console.log(myAkomando.getAkomaNtoso({
   serialize: 'HTMLString',
   addHeadElement: false,
   addBodyElement: false,
}));

// logs all meta FRBRcountry of the loaded AkomaNtoso as a JSON object
console.log(myAkomando.getMeta({
   serialize: 'JSON',
   metaRoot: 'FRBRthis',
}));

// logs all hierarchies identifiers of hierarchies having content of the loaded AkomaNtoso
console.log(myAkomando.getHierIdentifiers({
   filterByContent: true,
}));

// logs all hierarchies identifiers of hierarchies having content of the loaded AkomaNtoso
console.log(myAkomando.getHierIdentifiers({
   filterByContent: true,
}));

// Logs the number of all elements contained in the current AkomaNtoso document
console.log(myAkomando.countDocElements());

// Logs the number of all 'ref' elements contained in the current AkomaNtoso document
console.log(myAkomando.countDocElements({
   filterByName: 'ref',
}));

// Logs the list of references that are used at least by one element in the document
console.log(myAkomando.getReferencesInfo({
   filterBy: 'used'
}));

// logs an object containing all the components contained in
// the loaded AkomaNtoso as HTML Documents
console.log(myAkomando.getComponents({
    serialize: 'HTMLDom'
}));

In browser

In browser application use akomando as the following examples:

<html>
   <head>
      <title>akomando example getDocType</title>
   </head>
   <body>
      <script src="https://code.jquery.com/jquery-3.1.1.min.js"
              integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
              crossorigin="anonymous"></script>
      <script src="akomando.min.js" charset="UTF-8"></script>
      <script>
         // load the content of an AkomaNtoso file in some way. Here I use jQuery.
         var myAkomaNtosoString = $.ajax({
            url: 'my-akomantoso.xml',
            async: false
         }).responseText;

         var myAkomando =  akomando.createAkomando({
            aknString: myAkomaNtosoString,
         });
         console.log(myAkomando.getDocType());

         // logs the loaded AkomaNtoso as XLM String
         console.log(myAkomando.getAkomaNtoso({
            serialize: 'AKNString'
         });

         // logs the loaded AkomaNtoso as JSON
         console.log(myAkomando.getAkomaNtoso({
            serialize: 'JSON'
         }));

         // logs the raw text of the loaded AkomaNtoso without new lines characters
         console.log(myAkomando.getAkomaNtoso({
            serialize: 'TEXT'
            newLines: false,
         }));

         // logs the loaded AkomaNtoso as HTML String, without inserting the head element and the body element
         console.log(myAkomando.getAkomaNtoso({
            serialize: 'HTMLString',
            addHeadElement: false,
            addBodyElement: false,
         }));

         // logs all meta FRBRcountry of the loaded AkomaNtoso as a JSON object
         console.log(myAkomando.getMeta({
            serialize: 'JSON',
            metaRoot: 'FRBRthis',
         }));

         // logs all hierarchies identifiers of hierarchies having content of the loaded AkomaNtoso
         console.log(myAkomando.getHierIdentifiers({
            filterByContent: true
         }));

         // Logs the number of all elements contained in the current AkomaNtoso document
         console.log(myAkomando.countDocElements());

         // Logs the number of all 'ref' elements contained in the current AkomaNtoso document
         console.log(myAkomando.countDocElements({
            filterByName: 'ref',
         }));

         // Logs the list of references that are used at least by one element in the document
         console.log(myAkomando.getReferencesInfo({
            filterBy: 'used'
         }));

         // logs an object containing all the components contained in
         // the loaded AkomaNtoso as HTML Documents
         console.log(myAkomando.getComponents({
            serialize: 'HTMLDom'
         }));
      </script>
   </body>
</html>

As a command line tool

Akomando can be used as a command line tool as the following examples. Run akomando -h to have a full list of the available commands.

// returns the doc type of the AkomaNtoso file having path "path/to/file"
$ akomando get-doc-type <path/to/file>

// returns the AkomaNtoso file having path "path/to/file" as a JSON string
$ akomando get-akomantoso <path/to/file> -s json

// returns the AkomaNtoso file having path "path/to/file" as a HTML string without head and body elements
$ akomando get-akomantoso <path/to/file> -s html --no-head --no-body

// returns the raw text of the AkomaNtoso file having path "path/to/file" without new lines character
$ akomando get-akomantoso <path/to/file> -s text --no-new-lines

// returns the meta of the AkomaNtoso file having path "path/to/file" as an AkomaNtoso string
$ akomando get-meta <path/to/file>

// returns the meta of the AkomaNtoso file having path "path/to/file" as a JSON string
$ akomando get-meta <path/to/file> -s json

// returns all the meta of the AkomaNtoso file having path "path/to/file" ordering them descending
$ akomando get-hier-identifiers <path/to/file> --order descending

// returns all hierarchies identifiers of articles of the AkomaNtoso file having path "path/to/file"
$ akomando get-hier-identifiers <path/to/file> --filter-by-name article

// returns all hierarchies identifiers of hierarchis having content of the AkomaNtoso file having path "path/to/file"
$ akomando get-hier-identifiers <path/to/file> --filter-by-content

// returns the the number of all elements contained in the current AkomaNtoso document
$ akomando count-doc-elements <path/to/file>

// returns the number of all 'ref' elements contained in the current AkomaNtoso document
$ akomando count-doc-elements <path/to/file> --filter-by-name ref

// Logs the list of the elements that have a "source" attribute not connected to any TLC element in metadata
$ akomando get-references-info <path/to/file> --filter-by used

// logs the string representation of an object containing
// all the components contained in the loaded AkomaNtoso as JSON Objects
akomando get-components <path/to/file> -s json

Tests

When contributing to develop akomando, there are three tests types that must always pass.

Node test

Simply, run the following:

npm run test:node

CLI test

Simply, run the following:

npm run test:bin

Browser test

Simply, run the following:

npm run test:browser

If your default browser does not open automatically, then open it and go to the address:

http://localhost:8080/test/browser/test-browser.html

All tests

Simply, run the following:

npm run test

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add at least 3 unit tests for any new functionality. Be sure that any changed functionality continue to pass its dedicated tests. Lint and test your code.