New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bookshelf-fields

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookshelf-fields - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0

50

lib/bookshelf-fields.js

@@ -1,5 +0,5 @@

// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.10.0
(function() {
var CheckIt, deep_clone, enable_validation, exports, f, field, fields, k, plugin, _ref,
__slice = [].slice;
var CheckIt, deep_clone, enable_validation, exports, f, field, fields, k, plugin, ref,
slice = [].slice;

@@ -38,9 +38,9 @@ CheckIt = require('checkit');

var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return field.apply(null, [this].concat(__slice.call(args)));
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return field.apply(null, [this].concat(slice.call(args)));
};
instance.__helpers_fp.fields = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return fields.apply(null, [this].concat(__slice.call(args)));
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return fields.apply(null, [this].concat(slice.call(args)));
};

@@ -81,8 +81,8 @@ if (options == null) {

model.format = function(attrs, options) {
var f, _i, _len, _ref;
var f, i, len, ref;
attrs = old_format.call(this, attrs, options);
if ((this.__meta != null) && this.__meta.fields) {
_ref = this.__meta.fields;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
f = _ref[_i];
ref = this.__meta.fields;
for (i = 0, len = ref.length; i < len; i++) {
f = ref[i];
if ('format' in f) {

@@ -97,8 +97,8 @@ f.format(attrs, options);

return model.parse = function(resp, options) {
var attrs, f, _i, _len, _ref;
var attrs, f, i, len, ref;
attrs = old_parse.call(this, resp, options);
if ((this.__meta != null) && this.__meta.fields) {
_ref = this.__meta.fields;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
f = _ref[_i];
ref = this.__meta.fields;
for (i = 0, len = ref.length; i < len; i++) {
f = ref[i];
if ('parse' in f) {

@@ -139,10 +139,10 @@ f.parse(attrs, options);

fields = function() {
var cls, model, name, options, specs, _i, _len, _ref, _results;
model = arguments[0], specs = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
_results = [];
for (_i = 0, _len = specs.length; _i < _len; _i++) {
_ref = specs[_i], cls = _ref[0], name = _ref[1], options = _ref[2];
_results.push(field(model, cls, name, options));
var cls, i, len, model, name, options, ref, results, specs;
model = arguments[0], specs = 2 <= arguments.length ? slice.call(arguments, 1) : [];
results = [];
for (i = 0, len = specs.length; i < len; i++) {
ref = specs[i], cls = ref[0], name = ref[1], options = ref[2];
results.push(field(model, cls, name, options));
}
return _results;
return results;
};

@@ -157,5 +157,5 @@

_ref = require('./fields');
for (k in _ref) {
f = _ref[k];
ref = require('./fields');
for (k in ref) {
f = ref[k];
exports[k] = f;

@@ -162,0 +162,0 @@ }

@@ -1,8 +0,8 @@

// Generated by CoffeeScript 1.8.0
// Generated by CoffeeScript 1.10.0
(function() {
var BooleanField, DateField, DateTimeField, EmailField, Field, FloatField, IntField, JSONField, NumberField, StringField, e, isArray,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__slice = [].slice,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
slice = [].slice,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -18,9 +18,9 @@ isArray = require('util').isArray;

function Field(name, options) {
var _base;
this.name = name;
this.options = options != null ? options : {};
this._validate_choices = __bind(this._validate_choices, this);
if ((_base = this.options).create_property == null) {
_base.create_property = true;
function Field(name1, options1) {
var base;
this.name = name1;
this.options = options1 != null ? options1 : {};
this._validate_choices = bind(this._validate_choices, this);
if ((base = this.options).create_property == null) {
base.create_property = true;
}

@@ -44,3 +44,3 @@ this.validations = [];

Field.prototype.contribute_to_model = function(model) {
var proto, _base;
var base, proto;
this.model = model;

@@ -51,4 +51,4 @@ proto = model.prototype;

}
if ((_base = proto.__meta).fields == null) {
_base.fields = [];
if ((base = proto.__meta).fields == null) {
base.fields = [];
}

@@ -138,3 +138,3 @@ proto.__meta.fields.push(this);

case typeof rule !== 'string':
return "" + rule + ":" + value;
return rule + ":" + value;
default:

@@ -149,9 +149,9 @@ return this.normalize_rule(rule, {

Field.prototype._validate_choices = function() {
var choices, comparator, value, variant, _i, _len;
value = arguments[0], choices = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
var choices, comparator, i, len, value, variant;
value = arguments[0], choices = 2 <= arguments.length ? slice.call(arguments, 1) : [];
comparator = this.options.comparator != null ? this.options.comparator : function(a, b) {
return a === b;
};
for (_i = 0, _len = choices.length; _i < _len; _i++) {
variant = choices[_i];
for (i = 0, len = choices.length; i < len; i++) {
variant = choices[i];
if (comparator(value, variant)) {

@@ -165,3 +165,3 @@ return true;

Field.prototype._accept_rule = function(names, rule) {
var name, _i, _len;
var i, len, name;
if (!isArray(names)) {

@@ -173,4 +173,4 @@ names = [names];

}
for (_i = 0, _len = names.length; _i < _len; _i++) {
name = names[_i];
for (i = 0, len = names.length; i < len; i++) {
name = names[i];
if (!(name in this.options)) {

@@ -210,4 +210,4 @@ continue;

e.StringField = StringField = (function(_super) {
__extends(StringField, _super);
e.StringField = StringField = (function(superClass) {
extend(StringField, superClass);

@@ -224,4 +224,4 @@ function StringField(name, options) {

e.EmailField = EmailField = (function(_super) {
__extends(EmailField, _super);
e.EmailField = EmailField = (function(superClass) {
extend(EmailField, superClass);

@@ -237,4 +237,4 @@ function EmailField(name, options) {

e.NumberField = NumberField = (function(_super) {
__extends(NumberField, _super);
e.NumberField = NumberField = (function(superClass) {
extend(NumberField, superClass);

@@ -255,4 +255,4 @@ function NumberField(name, options) {

e.IntField = IntField = (function(_super) {
__extends(IntField, _super);
e.IntField = IntField = (function(superClass) {
extend(IntField, superClass);

@@ -274,8 +274,8 @@ function IntField(name, options) {

e.FloatField = FloatField = (function(_super) {
__extends(FloatField, _super);
e.FloatField = FloatField = (function(superClass) {
extend(FloatField, superClass);
function FloatField(name, options) {
FloatField.__super__.constructor.call(this, name, options);
this.validations.unshift(this._with_message('isNumeric'));
this.validations.unshift(this._with_message('numeric'));
}

@@ -293,4 +293,4 @@

e.BooleanField = BooleanField = (function(_super) {
__extends(BooleanField, _super);
e.BooleanField = BooleanField = (function(superClass) {
extend(BooleanField, superClass);

@@ -317,4 +317,4 @@ function BooleanField() {

e.DateTimeField = DateTimeField = (function(_super) {
__extends(DateTimeField, _super);
e.DateTimeField = DateTimeField = (function(superClass) {
extend(DateTimeField, superClass);

@@ -352,4 +352,4 @@ function DateTimeField(name, options) {

e.DateField = DateField = (function(_super) {
__extends(DateField, _super);
e.DateField = DateField = (function(superClass) {
extend(DateField, superClass);

@@ -380,4 +380,4 @@ function DateField() {

e.JSONField = JSONField = (function(_super) {
__extends(JSONField, _super);
e.JSONField = JSONField = (function(superClass) {
extend(JSONField, superClass);

@@ -384,0 +384,0 @@ function JSONField(name, options) {

{
"name": "bookshelf-fields",
"version": "0.3.2",
"version": "0.4.0",
"description": "Bookshelf fields",

@@ -22,13 +22,13 @@ "main": "lib/bookshelf-fields.js",

"chai": "*",
"chai-as-promised": "~4.1.0",
"chai-as-promised": "~5.1.0",
"coffee-script": "^1.7.1",
"knex": "^0.6.18",
"knex": "~0.8.0",
"mocha": "*",
"pg": "^3.3.0",
"sqlite3": "~2.2.3",
"pg": "~4.4.0",
"sqlite3": "~3.1.0",
"when": "^3.2.0"
},
"dependencies": {
"bookshelf": "~0.7.0",
"checkit": "~0.2.0-pre"
"bookshelf": "~0.8.0",
"checkit": "~0.5.0"
},

@@ -35,0 +35,0 @@ "scripts": {

@@ -39,3 +39,3 @@ bookshelf-fields

Fields = require 'bookshelf-fields'
db.plugin Fields.plugin
db.plugin Fields.plugin(options)

@@ -42,0 +42,0 @@ Now you are ready to add fields information to models. There are two equivalent ways to do it: with

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