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

papr

Package Overview
Dependencies
Maintainers
4
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

papr - npm Package Compare versions

Comparing version 7.2.2 to 7.3.0

cjs/TupleItems.d.ts

26

cjs/types.d.ts
import { Binary, ObjectId } from 'mongodb';
import { TupleItems } from './TupleItems';
import { Flatten } from './utils';

@@ -72,2 +73,3 @@ interface RequiredOptions {

declare function string<Options extends StringOptions>(options?: Options): GetType<string, Options>;
declare function tuple<Items extends readonly unknown[], Options extends GenericOptions>(items: Items, options?: Options): GetType<TupleItems<Items>, Options>;
declare function unknown<Options extends GenericOptions>(options?: Options): unknown;

@@ -354,2 +356,26 @@ declare const _default: {

/**
* Creates a tuple type for the items in the supplied items array.
*
* Items passed to tuple must be readonly to preserve their order and any optional properties preceding a required property are implicitly required as well.
*
* @param types {Type[]}
* @param [options] {GenericOptions}
* @param [options.required] {boolean}
*
* @example
* import { schema, types } from 'papr';
*
* schema({
* requiredTuple: types.tuple([
* types.number(),
* types.string()
* ] as const, { required: true }),
* optionalTuple: types.tuple([
* types.number(),
* types.string()
* ] as const),
* });
*/
tuple: typeof tuple;
/**
* We recommend avoiding this type. It only exists as an escape hatch for unknown data.

@@ -356,0 +382,0 @@ *

@@ -102,2 +102,3 @@ "use strict";

exports.objectGeneric = objectGeneric;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function oneOf(types, options) {

@@ -135,2 +136,17 @@ const { required } = options || {};

}
function tuple(items, options) {
const { required } = options || {};
const minItems = items.reduce((value, item, index) => {
if (item.$required)
return index + 1;
return value;
}, 0);
return {
...(required ? { $required: true } : {}),
items,
type: 'array',
minItems,
additionalItems: false,
};
}
function unknown(options) {

@@ -419,2 +435,26 @@ return any(options);

/**
* Creates a tuple type for the items in the supplied items array.
*
* Items passed to tuple must be readonly to preserve their order and any optional properties preceding a required property are implicitly required as well.
*
* @param types {Type[]}
* @param [options] {GenericOptions}
* @param [options.required] {boolean}
*
* @example
* import { schema, types } from 'papr';
*
* schema({
* requiredTuple: types.tuple([
* types.number(),
* types.string()
* ] as const, { required: true }),
* optionalTuple: types.tuple([
* types.number(),
* types.string()
* ] as const),
* });
*/
tuple,
/**
* We recommend avoiding this type. It only exists as an escape hatch for unknown data.

@@ -421,0 +461,0 @@ *

1

cjs/utils.js

@@ -201,2 +201,3 @@ "use strict";

key in (update.$unset || {})) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete $setOnInsert[key];

@@ -203,0 +204,0 @@ }

import { Binary, ObjectId } from 'mongodb';
import { TupleItems } from './TupleItems';
import { Flatten } from './utils';

@@ -72,2 +73,3 @@ interface RequiredOptions {

declare function string<Options extends StringOptions>(options?: Options): GetType<string, Options>;
declare function tuple<Items extends readonly unknown[], Options extends GenericOptions>(items: Items, options?: Options): GetType<TupleItems<Items>, Options>;
declare function unknown<Options extends GenericOptions>(options?: Options): unknown;

@@ -354,2 +356,26 @@ declare const _default: {

/**
* Creates a tuple type for the items in the supplied items array.
*
* Items passed to tuple must be readonly to preserve their order and any optional properties preceding a required property are implicitly required as well.
*
* @param types {Type[]}
* @param [options] {GenericOptions}
* @param [options.required] {boolean}
*
* @example
* import { schema, types } from 'papr';
*
* schema({
* requiredTuple: types.tuple([
* types.number(),
* types.string()
* ] as const, { required: true }),
* optionalTuple: types.tuple([
* types.number(),
* types.string()
* ] as const),
* });
*/
tuple: typeof tuple;
/**
* We recommend avoiding this type. It only exists as an escape hatch for unknown data.

@@ -356,0 +382,0 @@ *

@@ -96,2 +96,3 @@ /**

}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function oneOf(types, options) {

@@ -128,2 +129,17 @@ const { required } = options || {};

}
function tuple(items, options) {
const { required } = options || {};
const minItems = items.reduce((value, item, index) => {
if (item.$required)
return index + 1;
return value;
}, 0);
return {
...(required ? { $required: true } : {}),
items,
type: 'array',
minItems,
additionalItems: false,
};
}
function unknown(options) {

@@ -412,2 +428,26 @@ return any(options);

/**
* Creates a tuple type for the items in the supplied items array.
*
* Items passed to tuple must be readonly to preserve their order and any optional properties preceding a required property are implicitly required as well.
*
* @param types {Type[]}
* @param [options] {GenericOptions}
* @param [options.required] {boolean}
*
* @example
* import { schema, types } from 'papr';
*
* schema({
* requiredTuple: types.tuple([
* types.number(),
* types.string()
* ] as const, { required: true }),
* optionalTuple: types.tuple([
* types.number(),
* types.string()
* ] as const),
* });
*/
tuple,
/**
* We recommend avoiding this type. It only exists as an escape hatch for unknown data.

@@ -414,0 +454,0 @@ *

@@ -195,2 +195,3 @@ import { ObjectId } from 'mongodb';

key in (update.$unset || {})) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete $setOnInsert[key];

@@ -197,0 +198,0 @@ }

4

package.json

@@ -5,3 +5,3 @@ {

"author": "Plex Inc.",
"version": "7.2.2",
"version": "7.3.0",
"keywords": [

@@ -64,3 +64,3 @@ "mongodb",

"@types/jest": "28.1.7",
"@types/node": "14.18.23",
"@types/node": "14.18.26",
"@typescript-eslint/eslint-plugin": "5.33.0",

@@ -67,0 +67,0 @@ "@typescript-eslint/parser": "5.33.0",

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