@keupoz/mson-core
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

mson-core

This the core package of Mson TypeScript port used to load and parse Mson files.

Installation

npm install @keupoz/mson-core

Usage

import { ModelLoader } from '@keupoz/mson-core'

/**
 * Get actual model url. See `src/demo/modelLoader.ts` for example from demo
 */
function getModelUrl(modelId: string) {
  const [namespace, path] = modelId.split(':')

  return `path/to/${namespace}/models/${path}`
}

const modelLoader = new ModelLoader(async (modelId) => {
  const url = getModelUrl(modelId)

  const r = await fetch(url)
  const json = await r.json()

  return json
})

const parsedModel = await modelLoader.load('mson:steve')

console.log(parsedModel)

Readme

Keywords

none

Package Sidebar

Install

npm i @keupoz/mson-core

Weekly Downloads

5

Version

1.2.0

License

none

Unpacked Size

133 kB

Total Files

7

Last publish

Collaborators

  • keupoz