Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ts-common/property-set

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ts-common/property-set - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

12

index.d.ts

@@ -1,3 +0,3 @@

export declare type MapFunc<T, R> = <K extends keyof T>(k: K, v: T[K]) => R;
export declare function forEach<T>(source: T, func: MapFunc<T, void>): void;
export declare type MapFunc<T, R> = <K extends keyof T>(v: T[K], k: K) => R;
export declare const forEach: <T>(source: T, func: MapFunc<T, void>) => void;
export declare type PropertyFactory<T, K extends keyof T> = (k: K) => T[K];

@@ -7,10 +7,10 @@ export declare type Factory<T> = {

};
export declare function copyProperty<T>(value: T): <K extends keyof T>(k: K) => T[K];
export declare const copyProperty: <T>(value: T) => <K extends keyof T>(k: K) => T[K];
export declare type MutableOptional<T> = {
[K in keyof T]?: T[K];
};
export declare function create<T>(factory: Factory<T>): T;
export declare const create: <T>(factory: Factory<T>) => T;
export declare type PartialFactory<T> = {
readonly [K in keyof T]?: (k: K, v: T[K]) => T[K];
readonly [K in keyof T]?: (v: T[K], k: K) => T[K];
};
export declare function copyCreate<T>(source: T, factory: PartialFactory<T>): T;
export declare const copyCreate: <T>(source: T, factory: PartialFactory<T>) => T;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function forEach(source, func) {
exports.forEach = (source, func) => {
// tslint:disable-next-line:forin
for (const key in source) {
func(key, source[key]);
func(source[key], key);
}
}
exports.forEach = forEach;
function copyProperty(value) {
return (k) => value[k];
}
exports.copyProperty = copyProperty;
function fromMutableOptional(v) {
return v;
}
function setProperty(result, k, v) {
};
exports.copyProperty = (value) => (k) => value[k];
const fromMutableOptional = (v) => v;
const setProperty = (result, k, v) => {
if (v !== undefined) {

@@ -25,24 +19,23 @@ result[k] = v;

}
}
function create(factory) {
};
exports.create = (factory) => {
const result = {};
forEach(factory, (k, propertyFactory) => {
exports.forEach(factory, (propertyFactory, k) => {
setProperty(result, k, propertyFactory(k));
});
return fromMutableOptional(result);
}
exports.create = create;
function copyCreate(source, factory) {
};
exports.copyCreate = (source, factory) => {
const result = {};
forEach(source, (k, v) => {
exports.forEach(source, (v, k) => {
setProperty(result, k, v);
});
let changes = false;
forEach(factory, (k, propertyFactory) => {
exports.forEach(factory, (propertyFactory, k) => {
// tslint:disable-next-line:strict-type-predicates
if (propertyFactory !== undefined) {
const sourceK = source[k];
const newProperty = propertyFactory(k, sourceK);
if (sourceK !== newProperty) {
setProperty(result, k, newProperty);
const sourceValue = source[k];
const newValue = propertyFactory(sourceValue, k);
if (sourceValue !== newValue) {
setProperty(result, k, newValue);
changes = true;

@@ -53,3 +46,2 @@ }

return changes ? fromMutableOptional(result) : source;
}
exports.copyCreate = copyCreate;
};
{
"name": "@ts-common/property-set",
"version": "0.0.6",
"version": "0.0.7",
"description": "A set of properties",

@@ -5,0 +5,0 @@ "main": "index.js",

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