0.3.2 • Published 7 months ago

@neuledge/scalars v0.3.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

Neuledge Scalars

A set of Neuledge Engine scalars that can be used on the schema definition.

This library is not intended to be used directly. It is a dependency of the main package.

📦 Installation

npm install @neuledge/scalars

🚀 Getting started

import { Integer, String, DateTime } from '@neuledge/scalars';

// define the state scalars
const stateScalars = {
  id: { type: Integer, index: 1 },
  name: { type: String, index: 2 },
  description: { type: String, index: 3, nullable: true },
};

// validate a scalar value
const value: ScalarValue<typeof DateTime> = DateTime.encode(
  new Date('2020-01-01'),
); // 1577836800000

// decode a scalar value
const decodedValue: DateTime = DateTime.decode(value); // Date('2020-01-01')

📄 License

Neuledge is Apache 2.0 licensed.