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

factorial-form

Package Overview
Dependencies
Maintainers
5
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

factorial-form - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

.gitpod.yml

23

__tests__/Field.spec.ts

@@ -249,2 +249,25 @@ import { Field } from '../src'

})
describe('hasValue', () => {
it('returns true when value is set', () => {
const field = new Field('paco', 'string')
expect(field.hasValue).toBeTruthy()
})
it('returns false when value is null', () => {
const field = new Field(null, 'string')
expect(field.hasValue).toBeFalsy()
})
it('returns true when Field is boolean and value is false', () => {
const field = new Field(false, 'boolean')
expect(field.hasValue).toBeTruthy()
})
it('returns false when Field is string and value is false', () => {
const field = new Field(false, 'string')
expect(field.hasValue).toBeFalsy()
})
})
})

1

lib/index.d.ts

@@ -19,2 +19,3 @@ declare type Type = 'date' | 'timestamp' | 'number' | 'string' | 'file' | 'boolean' | 'cents' | 'any';

get isDirty(): boolean;
get hasValue(): boolean;
mapAndSet(value: any): void;

@@ -21,0 +22,0 @@ set(value: any): void;

27

lib/index.js

@@ -11,2 +11,3 @@ 'use strict';

var isObject = require('lodash/isObject');
var every = require('lodash/every');
var forEach = require('lodash/forEach');

@@ -27,2 +28,3 @@ var some = require('lodash/some');

var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
var every__default = /*#__PURE__*/_interopDefaultLegacy(every);
var forEach__default = /*#__PURE__*/_interopDefaultLegacy(forEach);

@@ -194,2 +196,16 @@ var some__default = /*#__PURE__*/_interopDefaultLegacy(some);

});
Object.defineProperty(Field.prototype, "hasValue", {
get: function () {
switch (this.type) {
case 'number':
case 'cents':
case 'boolean':
return this.value !== '' && !isNull__default['default'](this.value);
default:
return !!this.value;
}
},
enumerable: false,
configurable: true
});
Field.prototype.mapAndSet = function (value) {

@@ -301,12 +317,3 @@ this.value = this._mapIn(value);

get: function () {
return !some__default['default'](this.fields, function (field) {
switch (field.type) {
case 'number':
case 'cents':
case 'boolean':
return field.value === '' || isNull__default['default'](field.value);
default:
return !field.value;
}
});
return every__default['default'](this.fields, function (field) { return field.hasValue; });
},

@@ -313,0 +320,0 @@ enumerable: false,

{
"name": "factorial-form",
"version": "3.2.0",
"version": "3.2.1",
"description": "Factorial form library",

@@ -5,0 +5,0 @@ "repository": {

@@ -33,2 +33,3 @@ import typescript from 'rollup-plugin-typescript2';

'lodash/isEqual',
'lodash/every',
'moment',

@@ -35,0 +36,0 @@ 'flat',

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