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

@augment-vir/common

Package Overview
Dependencies
Maintainers
1
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@augment-vir/common - npm Package Compare versions

Comparing version 12.2.1 to 12.3.0

15

dist/cjs/augments/object/map-object.d.ts
import { UnPromise } from '../type';
import { PropertyValueType } from './object';
export type InnerMappedValues<EntireInputGeneric extends object, MappedValueGeneric> = {

@@ -7,2 +8,16 @@ [MappedProp in keyof EntireInputGeneric]: MappedValueGeneric;

/**
* Map an object's keys to new values synchronously. This is different from plain mapObjectValues in
* that this will not wrap the return value in a promise if any of the new object values are
* promises. This function also requires currying in order to get the types correct. This allows you
* to explicitly state the return type.
*
* @example
* mapObjectValuesSync({objectToIterateOver: 'initial value'})<{objectToIterateOver: number}>(
* (key, value) => ({
* newValue: value.length,
* }),
* );
*/
export declare function mapObjectValuesSync<EntireInputGeneric extends object>(inputObject: EntireInputGeneric): <OutputObjectGeneric extends object>(mapCallback: (inputKey: keyof EntireInputGeneric, keyValue: EntireInputGeneric[keyof EntireInputGeneric], fullObject: EntireInputGeneric) => never extends PropertyValueType<OutputObjectGeneric> ? any : PropertyValueType<OutputObjectGeneric>) => OutputObjectGeneric;
/**
* Creates a new object with the same properties as the input object, but with values set to the

@@ -9,0 +24,0 @@ * result of mapCallback for each property.

29

dist/cjs/augments/object/map-object.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapObjectValues = void 0;
exports.mapObjectValues = exports.mapObjectValuesSync = void 0;
const object_entries_1 = require("./object-entries");
/**
* Map an object's keys to new values synchronously. This is different from plain mapObjectValues in
* that this will not wrap the return value in a promise if any of the new object values are
* promises. This function also requires currying in order to get the types correct. This allows you
* to explicitly state the return type.
*
* @example
* mapObjectValuesSync({objectToIterateOver: 'initial value'})<{objectToIterateOver: number}>(
* (key, value) => ({
* newValue: value.length,
* }),
* );
*/
function mapObjectValuesSync(inputObject) {
function innerMap(mapCallback) {
const mappedObject = (0, object_entries_1.getObjectTypedKeys)(inputObject).reduce((accum, currentKey) => {
const mappedValue = mapCallback(currentKey, inputObject[currentKey], inputObject);
return {
...accum,
[currentKey]: mappedValue,
};
}, {});
return mappedObject;
}
return innerMap;
}
exports.mapObjectValuesSync = mapObjectValuesSync;
/**
* Creates a new object with the same properties as the input object, but with values set to the

@@ -7,0 +34,0 @@ * result of mapCallback for each property.

import { UnPromise } from '../type';
import { PropertyValueType } from './object';
export type InnerMappedValues<EntireInputGeneric extends object, MappedValueGeneric> = {

@@ -7,2 +8,16 @@ [MappedProp in keyof EntireInputGeneric]: MappedValueGeneric;

/**
* Map an object's keys to new values synchronously. This is different from plain mapObjectValues in
* that this will not wrap the return value in a promise if any of the new object values are
* promises. This function also requires currying in order to get the types correct. This allows you
* to explicitly state the return type.
*
* @example
* mapObjectValuesSync({objectToIterateOver: 'initial value'})<{objectToIterateOver: number}>(
* (key, value) => ({
* newValue: value.length,
* }),
* );
*/
export declare function mapObjectValuesSync<EntireInputGeneric extends object>(inputObject: EntireInputGeneric): <OutputObjectGeneric extends object>(mapCallback: (inputKey: keyof EntireInputGeneric, keyValue: EntireInputGeneric[keyof EntireInputGeneric], fullObject: EntireInputGeneric) => never extends PropertyValueType<OutputObjectGeneric> ? any : PropertyValueType<OutputObjectGeneric>) => OutputObjectGeneric;
/**
* Creates a new object with the same properties as the input object, but with values set to the

@@ -9,0 +24,0 @@ * result of mapCallback for each property.

import { getObjectTypedKeys } from './object-entries';
/**
* Map an object's keys to new values synchronously. This is different from plain mapObjectValues in
* that this will not wrap the return value in a promise if any of the new object values are
* promises. This function also requires currying in order to get the types correct. This allows you
* to explicitly state the return type.
*
* @example
* mapObjectValuesSync({objectToIterateOver: 'initial value'})<{objectToIterateOver: number}>(
* (key, value) => ({
* newValue: value.length,
* }),
* );
*/
export function mapObjectValuesSync(inputObject) {
function innerMap(mapCallback) {
const mappedObject = getObjectTypedKeys(inputObject).reduce((accum, currentKey) => {
const mappedValue = mapCallback(currentKey, inputObject[currentKey], inputObject);
return {
...accum,
[currentKey]: mappedValue,
};
}, {});
return mappedObject;
}
return innerMap;
}
/**
* Creates a new object with the same properties as the input object, but with values set to the

@@ -4,0 +30,0 @@ * result of mapCallback for each property.

import { UnPromise } from '../type';
import { PropertyValueType } from './object';
export type InnerMappedValues<EntireInputGeneric extends object, MappedValueGeneric> = {

@@ -7,2 +8,16 @@ [MappedProp in keyof EntireInputGeneric]: MappedValueGeneric;

/**
* Map an object's keys to new values synchronously. This is different from plain mapObjectValues in
* that this will not wrap the return value in a promise if any of the new object values are
* promises. This function also requires currying in order to get the types correct. This allows you
* to explicitly state the return type.
*
* @example
* mapObjectValuesSync({objectToIterateOver: 'initial value'})<{objectToIterateOver: number}>(
* (key, value) => ({
* newValue: value.length,
* }),
* );
*/
export declare function mapObjectValuesSync<EntireInputGeneric extends object>(inputObject: EntireInputGeneric): <OutputObjectGeneric extends object>(mapCallback: (inputKey: keyof EntireInputGeneric, keyValue: EntireInputGeneric[keyof EntireInputGeneric], fullObject: EntireInputGeneric) => never extends PropertyValueType<OutputObjectGeneric> ? any : PropertyValueType<OutputObjectGeneric>) => OutputObjectGeneric;
/**
* Creates a new object with the same properties as the input object, but with values set to the

@@ -9,0 +24,0 @@ * result of mapCallback for each property.

6

package.json
{
"name": "@augment-vir/common",
"version": "12.2.1",
"version": "12.3.0",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",

@@ -27,6 +27,6 @@ "bugs": {

"dependencies": {
"type-fest": "^3.5.3"
"type-fest": "^3.5.6"
},
"devDependencies": {
"typescript": "^4.9.4"
"typescript": "^4.9.5"
},

@@ -33,0 +33,0 @@ "publishConfig": {

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