Sha256: 9bebbf3981251fec28220782c4b250c9fe8c5167aae0daa64d952f74fd6475a2
Contents?: true
Size: 645 Bytes
Versions: 16
Compression:
Stored size: 645 Bytes
Contents
const mongoose = require('mongoose/browser'); const cql = require('cql-execution'); function Ratio(key, options) { mongoose.SchemaType.call(this, key, options, 'Ratio'); } Ratio.prototype = Object.create(mongoose.SchemaType.prototype); Ratio.prototype.cast = (ratio) => { if (typeof ratio.numerator === 'undefined') { throw new Error(`Ratio: ${ratio} does not have a numerator`); } else if (typeof ratio.denominator === 'undefined') { throw new Error(`Ratio: ${ratio} does not have a denominator`); } return new cql.Ratio(ratio.numerator, ratio.denominator); }; mongoose.Schema.Types.Ratio = Ratio; module.exports = Ratio;
Version data entries
16 entries across 16 versions & 1 rubygems