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

@tanstack/form-core

Package Overview
Dependencies
Maintainers
2
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/form-core - npm Package Compare versions

Comparing version 0.18.0 to 0.18.1

3

dist/esm/index.js
import { FormApi } from "./FormApi.js";
import { FieldApi } from "./FieldApi.js";
import { deleteBy, functionalUpdate, getAsyncValidatorArray, getBy, getSyncValidatorArray, isNonEmptyArray, setBy } from "./utils.js";
import { deleteBy, functionalUpdate, getAsyncValidatorArray, getBy, getSyncValidatorArray, isNonEmptyArray, makePathArray, setBy } from "./utils.js";
import { mergeForm, mutateMergeDeep } from "./mergeForm.js";

@@ -14,2 +14,3 @@ export {

isNonEmptyArray,
makePathArray,
mergeForm,

@@ -16,0 +17,0 @@ mutateMergeDeep,

@@ -19,2 +19,3 @@ import type { ValidationCause } from './types.js';

export declare function deleteBy(obj: any, _path: any): any;
export declare function makePathArray(str: string): (string | number)[];
export declare function isNonEmptyArray(obj: any): boolean;

@@ -21,0 +22,0 @@ interface AsyncValidatorArrayPartialOptions<T> {

@@ -93,3 +93,3 @@ function functionalUpdate(updater, input) {

}
return str.replace("[", ".").replace("]", "").replace(reFindNumbers0, intReplace).replace(reFindNumbers1, `.${intReplace}.`).replace(reFindNumbers2, `${intReplace}.`).replace(reFindNumbers3, `.${intReplace}`).replace(reFindMultiplePeriods, ".").split(".").map((d) => {
return str.replaceAll("[", ".").replaceAll("]", "").replace(reFindNumbers0, intReplace).replace(reFindNumbers1, `.${intReplace}.`).replace(reFindNumbers2, `${intReplace}.`).replace(reFindNumbers3, `.${intReplace}`).replace(reFindMultiplePeriods, ".").split(".").map((d) => {
if (d.indexOf(intPrefix) === 0) {

@@ -175,4 +175,5 @@ return parseInt(d.substring(intPrefix.length), 10);

isNonEmptyArray,
makePathArray,
setBy
};
//# sourceMappingURL=utils.js.map
{
"name": "@tanstack/form-core",
"version": "0.18.0",
"version": "0.18.1",
"description": "Powerful, type-safe, framework agnostic forms.",

@@ -5,0 +5,0 @@ "author": "tannerlinsley",

import { describe, expect, it } from 'vitest'
import { deleteBy, getBy, setBy } from '../utils'
import { deleteBy, getBy, makePathArray, setBy } from '../utils'

@@ -8,4 +8,4 @@ describe('getBy', () => {

kids: [
{ name: 'Stephen', age: 10 },
{ name: 'Taylor', age: 15 },
{ name: 'Stephen', age: 10, hobbies: ['soccer', 'reading'] },
{ name: 'Taylor', age: 15, hobbies: ['swimming', 'gaming'] },
],

@@ -26,2 +26,11 @@ mother: {

})
it('should get nested array subfields by path', () => {
expect(getBy(structure, 'kids[0].hobbies[0]')).toBe(
structure.kids[0]!.hobbies[0],
)
expect(getBy(structure, 'kids[0].hobbies[1]')).toBe(
structure.kids[0]!.hobbies[1],
)
})
})

@@ -33,4 +42,4 @@

kids: [
{ name: 'Stephen', age: 10 },
{ name: 'Taylor', age: 15 },
{ name: 'Stephen', age: 10, hobbies: ['soccer', 'reading'] },
{ name: 'Taylor', age: 15, hobbies: ['swimming', 'gaming'] },
],

@@ -53,2 +62,11 @@ mother: {

})
it('should set nested array subfields by path', () => {
expect(
setBy(structure, 'kids[0].hobbies[0]', 'swimming').kids[0].hobbies[0],
).toBe('swimming')
expect(
setBy(structure, 'kids[0].hobbies[1]', 'gaming').kids[0].hobbies[1],
).toBe('gaming')
})
})

@@ -60,4 +78,4 @@

kids: [
{ name: 'Stephen', age: 10 },
{ name: 'Taylor', age: 15 },
{ name: 'Stephen', age: 10, hobbies: ['soccer', 'reading'] },
{ name: 'Taylor', age: 15, hobbies: ['swimming', 'gaming'] },
],

@@ -79,2 +97,11 @@ mother: {

it('should delete nested array subfields by path', () => {
expect(deleteBy(structure, 'kids[0].hobbies[0]').kids[0].hobbies[0]).toBe(
'reading',
)
expect(
deleteBy(structure, 'kids[0].hobbies[1]').kids[0].hobbies[1],
).not.toBeDefined()
})
it('should delete non-existent paths like a noop', () => {

@@ -87,1 +114,25 @@ expect(deleteBy(structure, 'nonexistent')).toEqual(structure)

})
describe('makePathArray', () => {
it('should convert dot notation to array', () => {
expect(makePathArray('name')).toEqual(['name'])
expect(makePathArray('mother.name')).toEqual(['mother', 'name'])
expect(makePathArray('kids[0].name')).toEqual(['kids', 0, 'name'])
expect(makePathArray('kids[0].name[1]')).toEqual(['kids', 0, 'name', 1])
expect(makePathArray('kids[0].name[1].age')).toEqual([
'kids',
0,
'name',
1,
'age',
])
expect(makePathArray('kids[0].name[1].age[2]')).toEqual([
'kids',
0,
'name',
1,
'age',
2,
])
})
})

@@ -129,3 +129,3 @@ import type { ValidationCause } from './types'

function makePathArray(str: string) {
export function makePathArray(str: string) {
if (typeof str !== 'string') {

@@ -136,4 +136,4 @@ throw new Error('Path must be a string.')

return str
.replace('[', '.')
.replace(']', '')
.replaceAll('[', '.')
.replaceAll(']', '')
.replace(reFindNumbers0, intReplace)

@@ -140,0 +140,0 @@ .replace(reFindNumbers1, `.${intReplace}.`)

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