Socket
Socket
Sign inDemoInstall

tcomb

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tcomb - npm Package Compare versions

Comparing version 2.6.0 to 2.7.0

index.d.ts

11

CHANGELOG.md

@@ -15,2 +15,13 @@ # Changelog

# v2.7.0
- **New Feature**
- `lib/fromJSON` module: generic deserialize, fix #169
- `lib/fromJSON` TypeScript definition file
- **Bug Fix**
- t.update module: $apply doesn't play well with dates and regexps, fix #172
- t.update: cannot $merge and $remove at once, fix #170 (thanks @grahamlyus)
- TypeScript: fix Exported external package typings file '...' is not a module
- misleading error message in `Struct.extend` functions, fix #177 (thanks @Firfi)
# v2.6.0

@@ -17,0 +28,0 @@

4

lib/dict.js

@@ -87,4 +87,4 @@ var assert = require('./assert');

Dict.update = function (instance, spec) {
return Dict(assert.update(instance, spec));
Dict.update = function (instance, patch) {
return Dict(assert.update(instance, patch));
};

@@ -91,0 +91,0 @@

@@ -48,4 +48,4 @@ var assert = require('./assert');

Intersection.update = function (instance, spec) {
return Intersection(assert.update(instance, spec));
Intersection.update = function (instance, patch) {
return Intersection(assert.update(instance, patch));
};

@@ -52,0 +52,0 @@

@@ -73,4 +73,4 @@ var assert = require('./assert');

List.update = function (instance, spec) {
return List(assert.update(instance, spec));
List.update = function (instance, patch) {
return List(assert.update(instance, patch));
};

@@ -77,0 +77,0 @@

@@ -56,4 +56,4 @@ var assert = require('./assert');

Refinement.update = function (instance, spec) {
return Refinement(assert.update(instance, spec));
Refinement.update = function (instance, patch) {
return Refinement(assert.update(instance, patch));
};

@@ -60,0 +60,0 @@

@@ -23,3 +23,3 @@ var assert = require('./assert');

return isObject(x) || isStruct(x);
}), function () { return 'Invalid argument mixins supplied to extend(mixins, name), expected an array of objects or types'; });
}), function () { return 'Invalid argument mixins supplied to extend(mixins, name), expected an array of objects or structs'; });
}

@@ -93,4 +93,4 @@ var props = {};

Struct.update = function (instance, spec) {
return new Struct(assert.update(instance, spec));
Struct.update = function (instance, patch) {
return new Struct(assert.update(instance, patch));
};

@@ -97,0 +97,0 @@

@@ -75,4 +75,4 @@ var assert = require('./assert');

Tuple.update = function (instance, spec) {
return Tuple(assert.update(instance, spec));
Tuple.update = function (instance, patch) {
return Tuple(assert.update(instance, patch));
};

@@ -79,0 +79,0 @@

@@ -81,4 +81,4 @@ var assert = require('./assert');

Union.update = function (instance, spec) {
return Union(assert.update(instance, spec));
Union.update = function (instance, patch) {
return Union(assert.update(instance, patch));
};

@@ -85,0 +85,0 @@

@@ -7,9 +7,20 @@ var assert = require('./assert');

var mixin = require('./mixin');
var getShallowCopy = require('./getShallowCopy');
// immutability helper
function update(instance, spec) {
function getShallowCopy(x) {
if (isArray(x)) {
return x.concat();
}
if (x instanceof Date || x instanceof RegExp) {
return x;
}
if (isObject(x)) {
return mixin({}, x);
}
return x;
}
function update(instance, patch) {
if (process.env.NODE_ENV !== 'production') {
assert(isObject(spec), function () { return 'Invalid argument spec ' + assert.stringify(spec) + ' supplied to function update(instance, spec): expected an object containing commands'; });
assert(isObject(patch), function () { return 'Invalid argument patch ' + assert.stringify(patch) + ' supplied to function update(instance, patch): expected an object containing commands'; });
}

@@ -19,9 +30,10 @@

var isChanged = false;
for (var k in spec) {
if (spec.hasOwnProperty(k)) {
for (var k in patch) {
if (patch.hasOwnProperty(k)) {
if (update.commands.hasOwnProperty(k)) {
return update.commands[k](spec[k], value);
value = update.commands[k](patch[k], value);
isChanged = true;
}
else {
var newValue = update(value[k], spec[k]);
var newValue = update(value[k], patch[k]);
isChanged = isChanged || ( newValue !== value[k] );

@@ -28,0 +40,0 @@ value[k] = newValue;

{
"name": "tcomb",
"version": "2.6.0",
"version": "2.7.0",
"description": "Type checking and DDD for JavaScript",
"main": "index.js",
"typings": "tcomb.d.ts",
"typings": "index.d.ts",
"files": [
"index.js",
"lib",
"tcomb.d.ts"
"index.d.ts"
],

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

@@ -176,3 +176,3 @@ [![build status](https://img.shields.io/travis/gcanti/tcomb/master.svg?style=flat-square)](https://travis-ci.org/gcanti/tcomb)

[tcomb.d.ts](tcomb.d.ts)
[index.d.ts](index.d.ts)

@@ -182,3 +182,4 @@ # Contributors

- [Giulio Canti](https://github.com/gcanti) mantainer
- [Becky Conning](https://github.com/beckyconning) `func` combinator ideas and documentation.
- [Becky Conning](https://github.com/beckyconning) `func` combinator ideas and documentation
- [Andrea Lattuada](https://github.com/utaal) `declare` combinator

@@ -185,0 +186,0 @@ # Similar projects

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