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

generic-type-guard

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generic-type-guard - npm Package Compare versions

Comparing version 3.4.1 to 3.5.0

1

.eslintrc.js

@@ -5,2 +5,3 @@ module.exports = {

'@mscharley',
'@mscharley/eslint-config/node',
],

@@ -7,0 +8,0 @@ overrides: [

{
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#6472e7",
"activityBar.activeBorder": "#f2acb4",
"activityBar.background": "#6472e7",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#f2acb4",
"activityBarBadge.foreground": "#15202b",
"titleBar.activeBackground": "#384ae0",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#384ae099",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#384ae0"
}

13

CONTRIBUTING.md
# Install
```
yarn install
npm install
```

@@ -10,4 +10,4 @@

```
yarn build
yarn test
npm build
npm test
```

@@ -17,6 +17,9 @@

Ensure you're logged in with `npm login` and `yarn login`.
Ensure you're logged in with `npm login`.
```
yarn lerna publish
npm version <bump-type>
npm publish
```
Don't forget to commit and tag the version bump for GitHub releases too.

@@ -9,3 +9,7 @@ "use strict";

*/
var isUnion = function (ptt, ptu) { return function (o) { return ptt(o) || ptu(o); }; };
var isUnion = function (ptt, ptu) {
return function (o) {
return ptt(o) || ptu(o);
};
};
exports.isUnion = isUnion;

@@ -17,4 +21,8 @@ /**

*/
var isIntersection = function (ptt, ptu) { return function (o) { return ptt(o) && ptu(o); }; };
var isIntersection = function (ptt, ptu) {
return function (o) {
return ptt(o) && ptu(o);
};
};
exports.isIntersection = isIntersection;
//# sourceMappingURL=functions.js.map

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,2 +0,1 @@

/**

@@ -26,3 +25,3 @@ * Asserts that a guard is successful.

*
* @param guards A list of partial typeguards to string together.
* @param guards - A list of partial typeguards to string together.
*

@@ -387,2 +386,9 @@ * @public

/**
* Validate if an object is a Set containing elements of a given type.
*
* @public
*/
export declare const isSetOf: <T>(tg: TypeGuard<T>) => (o: unknown) => o is Set<T>;
/**
* Validate if a value is a specific javascript number.

@@ -389,0 +395,0 @@ *

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -11,6 +11,8 @@ "use strict";

*/
var hasProperty = function (property, value) { return function (o) {
// If the property exists and conforms to the value type guard.
return value(o[property]);
}; };
var hasProperty = function (property, value) {
return function (o) {
// If the property exists and conforms to the value type guard.
return value(o[property]);
};
};
exports.hasProperty = hasProperty;

@@ -22,7 +24,9 @@ /**

*/
var hasOptionalProperty = function (property, value) { return function (o) {
return !(property in o) ||
// If the property exists and conforms to the value type guard.
value(o[property]);
}; };
var hasOptionalProperty = function (property, value) {
return function (o) {
return !(property in o) ||
// If the property exists and conforms to the value type guard.
value(o[property]);
};
};
exports.hasOptionalProperty = hasOptionalProperty;

@@ -36,5 +40,7 @@ /**

*/
var isRecord = function (property, value) { return function (o) {
return primitives_1.isObject(o) && exports.hasProperty(property, value)(o);
}; };
var isRecord = function (property, value) {
return function (o) {
return primitives_1.isObject(o) && exports.hasProperty(property, value)(o);
};
};
exports.isRecord = isRecord;

@@ -63,3 +69,2 @@ /**

}
/* eslint-disable-next-line @typescript-eslint/no-magic-numbers */
return !enforce || n > 0;

@@ -92,3 +97,2 @@ };

}
/* eslint-disable-next-line @typescript-eslint/no-magic-numbers */
return !enforce || n > 0;

@@ -103,3 +107,7 @@ };

*/
var isInstance = function (klass) { return function (o) { return o instanceof klass; }; };
var isInstance = function (klass) {
return function (o) {
return o instanceof klass;
};
};
exports.isInstance = isInstance;

@@ -114,10 +122,12 @@ /**

*/
var hasProperties = function (props) { return function (o) {
for (var prop in props) {
if (!exports.hasProperty(prop, props[prop])(o)) {
return false;
var hasProperties = function (props) {
return function (o) {
for (var prop in props) {
if (!exports.hasProperty(prop, props[prop])(o)) {
return false;
}
}
}
return true;
}; };
return true;
};
};
exports.hasProperties = hasProperties;

@@ -131,18 +141,20 @@ /**

*/
var hasOnlyProperties = function (props) { return function (o) {
var found = [];
for (var prop in o) {
if (prop in props) {
var propsKey = prop;
if (!exports.hasProperty(propsKey, props[propsKey])(o)) {
var hasOnlyProperties = function (props) {
return function (o) {
var found = [];
for (var prop in o) {
if (prop in props) {
var propsKey = prop;
if (!exports.hasProperty(propsKey, props[propsKey])(o)) {
return false;
}
found.push(propsKey);
}
else {
return false;
}
found.push(propsKey);
}
else {
return false;
}
}
return found.length === Object.keys(props).length;
}; };
return found.length === Object.keys(props).length;
};
};
exports.hasOnlyProperties = hasOnlyProperties;

@@ -157,10 +169,12 @@ /**

*/
var hasOptionalProperties = function (props) { return function (o) {
for (var prop in props) {
if (!exports.hasOptionalProperty(prop, props[prop])(o)) {
return false;
var hasOptionalProperties = function (props) {
return function (o) {
for (var prop in props) {
if (!exports.hasOptionalProperty(prop, props[prop])(o)) {
return false;
}
}
}
return true;
}; };
return true;
};
};
exports.hasOptionalProperties = hasOptionalProperties;

@@ -167,0 +181,0 @@ /**

"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
exports.__esModule = true;
exports.isNever = exports.isUnknown = exports.isAny = exports.isSet = exports.isObject = exports.isObjectLike = exports.narrowArray = exports.narrowValue = exports.isArray = exports.isMissing = exports.isNullable = exports.isOptional = exports.isUndefined = exports.isNull = exports.isBoolean = exports.isSingletonStringUnion = exports.isSingletonString = exports.isString = exports.isSingletonNumberUnion = exports.isSingletonNumber = exports.isElementOf = exports.isNaN = exports.isInfinity = exports.isDouble = exports.isFloat = exports.isFiniteNumber = exports.isNumber = void 0;
exports.isNever = exports.isUnknown = exports.isAny = exports.isSet = exports.isObject = exports.isObjectLike = exports.isSetOf = exports.narrowArray = exports.narrowValue = exports.isArray = exports.isMissing = exports.isNullable = exports.isOptional = exports.isUndefined = exports.isNull = exports.isBoolean = exports.isSingletonStringUnion = exports.isSingletonString = exports.isString = exports.isSingletonNumberUnion = exports.isSingletonNumber = exports.isElementOf = exports.isNaN = exports.isInfinity = exports.isDouble = exports.isFloat = exports.isFiniteNumber = exports.isNumber = void 0;
var MINIMUM_ARRAY_INDEX = 0;

@@ -70,3 +91,5 @@ /**

}
return function (s) { return ss.indexOf(s) >= MINIMUM_ARRAY_INDEX; };
return function (s) {
return ss.indexOf(s) >= MINIMUM_ARRAY_INDEX;
};
});

@@ -78,3 +101,7 @@ /**

*/
var isSingletonNumber = function (v) { return function (n) { return n === v; }; };
var isSingletonNumber = function (v) {
return function (n) {
return n === v;
};
};
exports.isSingletonNumber = isSingletonNumber;

@@ -109,3 +136,7 @@ /**

*/
var isSingletonString = function (v) { return function (s) { return s === v; }; };
var isSingletonString = function (v) {
return function (s) {
return s === v;
};
};
exports.isSingletonString = isSingletonString;

@@ -156,3 +187,7 @@ /**

*/
var isOptional = function (tgt) { return function (o) { return typeof o === 'undefined' || tgt(o); }; };
var isOptional = function (tgt) {
return function (o) {
return typeof o === 'undefined' || tgt(o);
};
};
exports.isOptional = isOptional;

@@ -164,3 +199,7 @@ /**

*/
var isNullable = function (tgt) { return function (o) { return o === null || tgt(o); }; };
var isNullable = function (tgt) {
return function (o) {
return o === null || tgt(o);
};
};
exports.isNullable = isNullable;

@@ -172,5 +211,7 @@ /**

*/
var isMissing = function (tgt) { return function (o) {
return o == null || tgt(o);
}; };
var isMissing = function (tgt) {
return function (o) {
return o == null || tgt(o);
};
};
exports.isMissing = isMissing;

@@ -182,6 +223,8 @@ /**

*/
var isArray = function (valueCheck) { return function (arr) {
return Array.isArray(arr) &&
arr.reduce(function (acc, v) { return acc && valueCheck(v); }, true);
}; };
var isArray = function (valueCheck) {
return function (arr) {
return Array.isArray(arr) &&
arr.reduce(function (acc, v) { return acc && valueCheck(v); }, true);
};
};
exports.isArray = isArray;

@@ -193,3 +236,7 @@ /**

*/
var narrowValue = function (ptt, ptu) { return function (t) { return ptt(t) && ptu(t); }; };
var narrowValue = function (ptt, ptu) {
return function (t) {
return ptt(t) && ptu(t);
};
};
exports.narrowValue = narrowValue;

@@ -201,7 +248,21 @@ /**

*/
var narrowArray = function (pt) { return function (ts) {
return ts.reduce(function (acc, b) { return acc && pt(b); }, true);
}; };
var narrowArray = function (pt) {
return function (ts) {
return ts.reduce(function (acc, b) { return acc && pt(b); }, true);
};
};
exports.narrowArray = narrowArray;
/**
* Validate if an object is a Set containing elements of a given type.
*
* @public
*/
var isSetOf = function (tg) {
return function (o) {
return o instanceof Set &&
Array.of.apply(Array, __spreadArray([], __read(o.values()))).reduce(function (acc, v) { return acc && tg(v); }, true);
};
};
exports.isSetOf = isSetOf;
/**
* Validate if a value is like an object.

@@ -208,0 +269,0 @@ *

@@ -17,2 +17,13 @@ "use strict";

})();
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
exports.__esModule = true;

@@ -54,3 +65,3 @@ exports.combine = exports.assert = exports.AssertionError = void 0;

*
* @param guards A list of partial typeguards to string together.
* @param guards - A list of partial typeguards to string together.
*

@@ -65,8 +76,18 @@ * @public

return function (v) {
for (var _i = 0, guards_1 = guards; _i < guards_1.length; _i++) {
var guard = guards_1[_i];
if (!guard(v)) {
return false;
var e_1, _a;
try {
for (var guards_1 = __values(guards), guards_1_1 = guards_1.next(); !guards_1_1.done; guards_1_1 = guards_1.next()) {
var guard = guards_1_1.value;
if (!guard(v)) {
return false;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (guards_1_1 && !guards_1_1.done && (_a = guards_1["return"])) _a.call(guards_1);
}
finally { if (e_1) throw e_1.error; }
}
return true;

@@ -73,0 +94,0 @@ };

{
"name": "generic-type-guard",
"version": "3.4.1",
"version": "3.5.0",
"description": "Generic type guards for TypeScript",

@@ -70,23 +70,30 @@ "main": "dist/index.js",

"devDependencies": {
"@microsoft/api-extractor": "7.13.2",
"@mscharley/eslint-config": "1.3.2",
"@mscharley/prettier-config": "1.1.1",
"@stryker-mutator/core": "4.5.0",
"@stryker-mutator/mocha-runner": "4.5.0",
"@stryker-mutator/typescript-checker": "4.5.0",
"@types/chai": "4.2.15",
"@types/mocha": "8.2.1",
"@types/node": "12.20.4",
"chai": "4.3.3",
"codecov": "3.8.1",
"mocha": "8.3.1",
"nodemon": "2.0.7",
"@microsoft/api-extractor": "7.18.9",
"@mscharley/eslint-config": "1.6.3",
"@mscharley/prettier-config": "1.1.2",
"@stryker-mutator/core": "5.4.0",
"@stryker-mutator/mocha-runner": "5.4.0",
"@stryker-mutator/typescript-checker": "5.4.0",
"@types/chai": "4.2.21",
"@types/mocha": "9.0.0",
"@types/node": "12.20.25",
"@typescript-eslint/eslint-plugin": "4.31.1",
"@typescript-eslint/parser": "4.31.1",
"chai": "4.3.4",
"codecov": "3.8.3",
"eslint": "7.32.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-deprecation": "1.2.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "4.0.0",
"mocha": "9.1.1",
"nodemon": "2.0.12",
"nyc": "15.1.0",
"prettier": "2.2.1",
"prettier": "2.4.1",
"rimraf": "3.0.2",
"source-map-support": "0.5.19",
"testdouble": "3.16.1",
"ts-node": "9.1.1",
"typescript": "4.2.3"
"source-map-support": "0.5.20",
"testdouble": "3.16.2",
"ts-node": "10.2.1",
"typescript": "4.3.5"
}
}

@@ -0,0 +0,0 @@ # generic-type-guard

@@ -0,0 +0,0 @@ {

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

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

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