-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated GS1DigitalLinkToolkit.js to include exports method so it can …
…be called as an external Node library (src folder) Added decodeDigitalLinkURL.js script as an example script to call GS1DigitalLinkToolkit using node.
- Loading branch information
1 parent
deffa9e
commit 55a1bb3
Showing
2 changed files
with
1,913 additions
and
813 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Example JavaScript called from the command-line or within a Node.JS application. | ||
Node.JS v11 command line example (Ubuntu / Debian Linux) where this file and Gs1DigitalLinkToolkit.js are in the same folder: | ||
/usr/local/lib/nodejs/bin/node decodeDigitalLinkURL.js "https://id.gs1.org/gtin/05011157888163" | ||
*/ | ||
const GS1DigitalLinkToolkit = require("./GS1DigitalLinkToolkit"); | ||
let gs1dlt = new GS1DigitalLinkToolkit(); | ||
let structuredObject = {}; | ||
|
||
try | ||
{ | ||
structuredObject = gs1dlt.analyseURI(process.argv[2],true).structuredOutput; | ||
structuredObject.error = "OK"; | ||
} | ||
catch (err) | ||
{ | ||
structuredObject = { | ||
identifiers: [], | ||
qualifiers: [], | ||
dataAttributes: [], | ||
other: [], | ||
error: err.toString() | ||
} | ||
} | ||
console.log(JSON.stringify(structuredObject)); |