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

@fgv/ts-extras

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fgv/ts-extras - npm Package Compare versions

Comparing version 3.0.1-alpha.5 to 3.0.1-alpha.6

23

dist/ts-extras.d.ts

@@ -8,5 +8,7 @@ import { Conversion } from '@fgv/ts-utils';

export {
templateString,
extendedArrayOf,
rangeTypeOf,
rangeOf
rangeOf,
isoDate
}

@@ -202,4 +204,11 @@ }

/**
* A `Converter` which converts an iso formatted string, a number or a `Date` object to
* a `Date` object.
* @public
*/
declare const isoDate: Converter<Date, unknown>;
/**
* @public
*/
declare type JarFieldPicker<T extends JarRecord = JarRecord> = (record: T) => (keyof T)[];

@@ -406,2 +415,14 @@

/**
* Helper function to create a `StringConverter` which converts
* `unknown` to `string`, applying template conversions supplied at construction time or at
* runtime as context.
* @remarks
* Template conversions are applied using `mustache` syntax.
* @param defaultContext - Optional default context to use for template values.
* @returns A new `Converter` returning `string`.
* @public
*/
declare function templateString(defaultContext?: unknown): Conversion.StringConverter<string, unknown>;
export { }

2

dist/tsdoc-metadata.json

@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.

"packageName": "@microsoft/api-extractor",
"packageVersion": "7.39.4"
"packageVersion": "7.42.1"
}
]
}
import { Conversion, Converter, Result } from '@fgv/ts-utils';
import { ExtendedArray, RangeOf, RangeOfProperties } from '../experimental';
/**
* Helper function to create a `StringConverter` which converts
* `unknown` to `string`, applying template conversions supplied at construction time or at
* runtime as context.
* @remarks
* Template conversions are applied using `mustache` syntax.
* @param defaultContext - Optional default context to use for template values.
* @returns A new `Converter` returning `string`.
* @public
*/
export declare function templateString(defaultContext?: unknown): Conversion.StringConverter<string, unknown>;
/**
* A `Converter` which converts an iso formatted string, a number or a `Date` object to
* a `Date` object.
* @public
*/
export declare const isoDate: Converter<Date, unknown>;
/**
* A helper function to create a `Converter` which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.

@@ -5,0 +22,0 @@ * @remarks

@@ -23,7 +23,52 @@ "use strict";

*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.rangeOf = exports.rangeTypeOf = exports.extendedArrayOf = void 0;
exports.rangeOf = exports.rangeTypeOf = exports.extendedArrayOf = exports.isoDate = exports.templateString = void 0;
const ts_utils_1 = require("@fgv/ts-utils");
const luxon_1 = require("luxon");
const mustache_1 = __importDefault(require("mustache"));
const experimental_1 = require("../experimental");
/**
* Helper function to create a `StringConverter` which converts
* `unknown` to `string`, applying template conversions supplied at construction time or at
* runtime as context.
* @remarks
* Template conversions are applied using `mustache` syntax.
* @param defaultContext - Optional default context to use for template values.
* @returns A new `Converter` returning `string`.
* @public
*/
function templateString(defaultContext) {
return new ts_utils_1.Conversion.StringConverter(defaultContext, undefined, (from, __self, context) => {
if (typeof from !== 'string') {
return (0, ts_utils_1.fail)(`Not a string: ${JSON.stringify(from)}`);
}
return (0, ts_utils_1.captureResult)(() => mustache_1.default.render(from, context));
});
}
exports.templateString = templateString;
/**
* A `Converter` which converts an iso formatted string, a number or a `Date` object to
* a `Date` object.
* @public
*/
exports.isoDate = new ts_utils_1.Conversion.BaseConverter((from) => {
if (typeof from === 'string') {
const dt = luxon_1.DateTime.fromISO(from);
if (dt.isValid) {
return (0, ts_utils_1.succeed)(dt.toJSDate());
}
return (0, ts_utils_1.fail)(`Invalid date: ${dt.invalidExplanation}`);
}
else if (typeof from === 'number') {
return (0, ts_utils_1.succeed)(new Date(from));
}
else if (from instanceof Date) {
return (0, ts_utils_1.succeed)(from);
}
return (0, ts_utils_1.fail)(`Cannot convert ${JSON.stringify(from)} to Date`);
});
/**
* A helper function to create a `Converter` which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.

@@ -30,0 +75,0 @@ * @remarks

{
"name": "@fgv/ts-extras",
"version": "3.0.1-alpha.5",
"version": "3.0.1-alpha.6",
"description": "Assorted Typescript Utilities",

@@ -20,12 +20,12 @@ "main": "lib/index.js",

"@jest/expect-utils": "^29.7.0",
"@microsoft/api-documenter": "^7.23.20",
"@microsoft/api-extractor": "^7.39.4",
"@microsoft/api-documenter": "^7.23.34",
"@microsoft/api-extractor": "^7.42.1",
"@types/jest": "^29.5.12",
"@types/luxon": "^3.4.2",
"@types/mustache": "^4.2.5",
"@types/node": "^20.11.16",
"@types/node": "^20.11.24",
"@types/papaparse": "^5.3.14",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.56.0",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0",

@@ -44,10 +44,10 @@ "eslint-plugin-import": "^2.29.1",

"jest-snapshot": "~29.7.0",
"@rushstack/heft": "~0.64.3",
"@rushstack/heft-node-rig": "~2.4.5",
"@rushstack/eslint-config": "~3.6.2",
"@rushstack/heft": "~0.65.8",
"@rushstack/heft-node-rig": "~2.4.21",
"@rushstack/eslint-config": "~3.6.4",
"@types/heft-jest": "1.0.6",
"@rushstack/heft-jest-plugin": "~0.11.3",
"@rushstack/heft-jest-plugin": "~0.11.18",
"eslint-plugin-tsdoc": "~0.2.17",
"@fgv/ts-utils-jest": "3.0.1-alpha.5",
"@fgv/ts-utils": "3.0.1-alpha.5"
"@fgv/ts-utils-jest": "3.0.1-alpha.6",
"@fgv/ts-utils": "3.0.1-alpha.6"
},

@@ -60,3 +60,3 @@ "dependencies": {

"peerDependencies": {
"@fgv/ts-utils": "3.0.1-alpha.5"
"@fgv/ts-utils": "3.0.1-alpha.6"
},

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

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