Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

octonom

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

octonom - npm Package Compare versions

Comparing version 1.0.0-alpha.7 to 1.0.0-alpha.9

6

build/lib/schema.d.ts

@@ -5,2 +5,6 @@ export interface ISchemaValueBase {

}
export interface ISchemaValueAny extends ISchemaValueBase {
type: 'any';
default?: () => any;
}
export interface ISchemaValueArray extends ISchemaValueBase {

@@ -54,3 +58,3 @@ type: 'array';

}
export declare type SchemaValue = ISchemaValueArray | ISchemaValueBoolean | ISchemaValueDate | ISchemaValueModel | ISchemaValueNumber | ISchemaValueObject | ISchemaValueReference | ISchemaValueString;
export declare type SchemaValue = ISchemaValueAny | ISchemaValueArray | ISchemaValueBoolean | ISchemaValueDate | ISchemaValueModel | ISchemaValueNumber | ISchemaValueObject | ISchemaValueReference | ISchemaValueString;
export interface ISchemaMap {

@@ -57,0 +61,0 @@ [field: string]: SchemaValue;

@@ -65,2 +65,3 @@ "use strict";

return data;
case 'any':
case 'boolean':

@@ -143,2 +144,3 @@ case 'date':

return value;
case 'any':
case 'boolean':

@@ -145,0 +147,0 @@ case 'date':

@@ -14,2 +14,15 @@ import { ArrayCollection } from './array-collection';

describe('type any', () => {
const schemaAny: SchemaValue = {type: 'any', default: () => ({foo: 42})};
it('should return the input', () => {
const value = {foo: 'bar'};
expect(sanitize(schemaAny, value)).to.equal(value);
});
it('should return default value if undefined', () => {
expect(sanitize(schemaAny, undefined, {defaults: true})).to.eql({foo: 42});
});
});
describe('type array', () => {

@@ -301,2 +314,10 @@ const schemaStringArray: SchemaValue = {type: 'array', definition: {type: 'string'}};

describe('type any', () => {
it('should return the value', () => {
const schema: SchemaValue = {type: 'any'};
const value = {foo: 'bar'};
expect(toObjectValue(schema, value)).to.eql(value);
});
});
describe('type array', () => {

@@ -349,4 +370,5 @@ it('should clone an array', () => {

describe('types boolean, date, number, string', () => {
describe('types any, boolean, date, number, string', () => {
it('should just return the primitive', () => {
expect(toObjectValue({type: 'any'}, {foo: 'bar'})).to.eql({foo: 'bar'});
expect(toObjectValue({type: 'boolean'}, false)).to.equal(false);

@@ -353,0 +375,0 @@ const date = new Date();

13

lib/schema.ts

@@ -10,2 +10,7 @@ import { difference, forEach, isArray, isBoolean, isDate, isFunction, isNumber, isString } from 'lodash';

export interface ISchemaValueAny extends ISchemaValueBase {
type: 'any';
default?: () => any;
}
export interface ISchemaValueArray extends ISchemaValueBase {

@@ -68,5 +73,5 @@ type: 'array';

export type SchemaValue = ISchemaValueArray | ISchemaValueBoolean | ISchemaValueDate |
ISchemaValueModel | ISchemaValueNumber | ISchemaValueObject | ISchemaValueReference |
ISchemaValueString;
export type SchemaValue = ISchemaValueAny | ISchemaValueArray | ISchemaValueBoolean |
ISchemaValueDate | ISchemaValueModel | ISchemaValueNumber | ISchemaValueObject |
ISchemaValueReference | ISchemaValueString;

@@ -156,2 +161,3 @@ export interface ISchemaMap {

case 'any':
case 'boolean':

@@ -257,2 +263,3 @@ case 'date':

case 'any':
case 'boolean':

@@ -259,0 +266,0 @@ case 'date':

{
"name": "octonom",
"version": "1.0.0-alpha.7",
"version": "1.0.0-alpha.9",
"description": "Object Document Mapper for any database",

@@ -5,0 +5,0 @@ "main": "build/lib/main.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc