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

@commodo/fields

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commodo/fields - npm Package Compare versions

Comparing version 0.2.1 to 0.2.3

types.js

8

fields/boolean.js

@@ -10,3 +10,3 @@ "use strict";

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

@@ -21,2 +21,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
const boolean = (_ref = {}) => {

@@ -29,3 +33,3 @@ let {

return typeof value === "boolean";
}))((0, _createField.default)((0, _objectSpread2.default)({}, rest, {
}))((0, _createField.default)(_objectSpread({}, rest, {
list,

@@ -32,0 +36,0 @@ type: "boolean"

@@ -22,84 +22,81 @@ "use strict";

return function (parent) {
const instance = {
parent,
get,
set,
name: "",
type,
list,
validation,
current: null,
state: {
loading: false,
loaded: false,
dirty: false,
set: false
},
this.parent = parent;
this.get = get;
this.set = set;
this.name = "";
this.type = type;
this.list = list;
this.validation = validation;
this.current = null;
this.state = {
loading: false,
loaded: false,
dirty: false,
set: false
};
getValue() {
return this.current;
},
this.getValue = () => {
return this.current;
};
setValue(value, options = {}) {
// If needed, implement skipMarkAsSet option (at the time of implementation, it was not needed).
this.state.set = true;
this.setValue = (value, options = {}) => {
// If needed, implement skipMarkAsSet option (at the time of implementation, it was not needed).
this.state.set = true;
if (options.skipDifferenceCheck) {
if (options.forceSetAsDirty) {
this.state.dirty = true;
} else {
if (options.forceSetAsClean) {
this.state.dirty = false;
}
}
if (options.skipDifferenceCheck) {
if (options.forceSetAsDirty) {
this.state.dirty = true;
} else {
if (!this.state.dirty && this.isDifferentFrom(value)) {
this.state.dirty = true;
if (options.forceSetAsClean) {
this.state.dirty = false;
}
}
} else {
if (!this.state.dirty && this.isDifferentFrom(value)) {
this.state.dirty = true;
}
}
this.current = value;
return this;
},
this.current = value;
return this;
};
isDifferentFrom(value) {
return this.current !== value;
},
this.isDifferentFrom = value => {
return this.current !== value;
};
isDirty() {
return this.state.dirty;
},
this.isDirty = () => {
return this.state.dirty;
};
clean() {
this.state.dirty = false;
return this;
},
this.clean = () => {
this.state.dirty = false;
return this;
};
isEmpty() {
return this.current === null || typeof this.current === "undefined";
},
this.isEmpty = () => {
return this.current === null || typeof this.current === "undefined";
};
isSet() {
return this.state.set;
},
this.isSet = () => {
return this.state.set;
};
reset() {
this.current = null;
this.state.dirty = false;
this.state.set = false;
},
this.reset = () => {
this.current = null;
this.state.dirty = false;
this.state.set = false;
};
async validate() {
if (typeof this.validation === "function") {
await this.validation((await this.getValue()));
}
this.validate = async () => {
if (typeof this.validation === "function") {
await this.validation((await this.getValue()));
}
};
if ('value' in rest) {
instance.setValue(rest.value);
if ("value" in rest) {
this.setValue(rest.value);
}
return instance;
typeof this.construct === "function" && this.construct();
};

@@ -106,0 +103,0 @@ };

@@ -10,3 +10,3 @@ "use strict";

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

@@ -27,2 +27,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
const prepareValue = ({

@@ -111,3 +115,3 @@ value,

};
}))((0, _createField.default)((0, _objectSpread2.default)({}, rest, {
}))((0, _createField.default)(_objectSpread({}, rest, {
list,

@@ -114,0 +118,0 @@ type: "fields"

@@ -10,3 +10,3 @@ "use strict";

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

@@ -21,2 +21,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
const number = (_ref = {}) => {

@@ -29,3 +33,3 @@ let {

return typeof value === "number" && value > -Infinity && value < Infinity;
}))((0, _createField.default)((0, _objectSpread2.default)({}, rest, {
}))((0, _createField.default)(_objectSpread({}, rest, {
list,

@@ -32,0 +36,0 @@ type: "number"

@@ -10,3 +10,3 @@ "use strict";

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

@@ -21,2 +21,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
const string = (_ref = {}) => {

@@ -29,3 +33,3 @@ let {

return typeof value === "string";
}))((0, _createField.default)((0, _objectSpread2.default)({}, rest, {
}))((0, _createField.default)(_objectSpread({}, rest, {
list,

@@ -32,0 +36,0 @@ type: "string"

{
"name": "@commodo/fields",
"version": "0.2.1",
"version": "0.2.3",
"main": "index.js",

@@ -31,3 +31,3 @@ "repository": {

},
"gitHead": "1a5b35c9cb60ddf0cda12709d7cd634c254ee31c"
"gitHead": "9d0cf6fead541a8966d1fbbee638fc7aa436f771"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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