Skip to content

Latest commit

 

History

History

mson-core

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

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)