mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-02 09:47:00 +02:00
⚡ Adjust some implementations
This commit is contained in:
parent
6e2f54d644
commit
b9b966c8a1
|
|
@ -61,6 +61,7 @@
|
|||
"lodash.set": "^4.3.2",
|
||||
"luxon": "~2.3.0",
|
||||
"recast": "^0.21.5",
|
||||
"title-case": "^3.0.3",
|
||||
"transliteration": "^2.3.5",
|
||||
"xml2js": "^0.4.23"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,8 +199,9 @@ export function average(value: unknown[]) {
|
|||
}
|
||||
|
||||
function compact(value: unknown[]): unknown[] {
|
||||
console.log('value[4]', value[4]);
|
||||
return value
|
||||
.filter((v) => v !== null && v !== undefined)
|
||||
.filter((v) => v !== null && v !== undefined && v !== 'nil' && v !== '')
|
||||
.map((v) => {
|
||||
if (typeof v === 'object' && v !== null) {
|
||||
return oCompact(v);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ export function compact(value: object): object {
|
|||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const newObj: any = {};
|
||||
for (const [key, val] of Object.entries(value)) {
|
||||
if (val !== null && val !== undefined) {
|
||||
if (val !== null && val !== undefined && val !== 'nil' && val !== '') {
|
||||
if (typeof val === 'object') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
|
||||
newObj[key] = compact(val);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
// import { createHash } from 'crypto';
|
||||
import { titleCase } from 'title-case';
|
||||
import * as ExpressionError from '../ExpressionError';
|
||||
import type { ExtensionMap } from './Extensions';
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
|
@ -189,10 +190,6 @@ function replaceSpecialChars(value: string) {
|
|||
return transliterate(value, { unknown: '?' });
|
||||
}
|
||||
|
||||
function toTitleCase(value: string) {
|
||||
return value.replace(/\w\S*/g, (v) => v.charAt(0).toLocaleUpperCase() + v.slice(1));
|
||||
}
|
||||
|
||||
function toSentenceCase(value: string) {
|
||||
let current = value.slice();
|
||||
let buffer = '';
|
||||
|
|
@ -270,7 +267,7 @@ export const stringExtensions: ExtensionMap = {
|
|||
toWholeNumber: toInt,
|
||||
toSentenceCase,
|
||||
toSnakeCase,
|
||||
toTitleCase,
|
||||
toTitleCase: titleCase,
|
||||
urlDecode,
|
||||
urlEncode,
|
||||
quote,
|
||||
|
|
|
|||
|
|
@ -143,16 +143,6 @@ describe('Data Transformation Functions', () => {
|
|||
expect(evaluate('={{ "i am a test".toSentenceCase() }}')).toEqual('I am a test');
|
||||
});
|
||||
|
||||
test('.toTitleCase should work on a string', () => {
|
||||
expect(
|
||||
evaluate(
|
||||
'={{ "i am a test! i have multiple types of Punctuation. or do i?".toTitleCase() }}',
|
||||
),
|
||||
).toEqual('I Am A Test! I Have Multiple Types Of Punctuation. Or Do I?');
|
||||
expect(evaluate('={{ "i am a test!".toTitleCase() }}')).toEqual('I Am A Test!');
|
||||
expect(evaluate('={{ "i am a test".toTitleCase() }}')).toEqual('I Am A Test');
|
||||
});
|
||||
|
||||
test('.extractUrl should work on a string', () => {
|
||||
expect(
|
||||
evaluate(
|
||||
|
|
|
|||
|
|
@ -905,6 +905,7 @@ importers:
|
|||
lodash.set: ^4.3.2
|
||||
luxon: ~2.3.0
|
||||
recast: ^0.21.5
|
||||
title-case: ^3.0.3
|
||||
transliteration: ^2.3.5
|
||||
xml2js: ^0.4.23
|
||||
dependencies:
|
||||
|
|
@ -918,6 +919,7 @@ importers:
|
|||
lodash.set: 4.3.2
|
||||
luxon: 2.3.2
|
||||
recast: 0.21.5
|
||||
title-case: 3.0.3
|
||||
transliteration: 2.3.5
|
||||
xml2js: 0.4.23
|
||||
devDependencies:
|
||||
|
|
@ -20433,7 +20435,6 @@ packages:
|
|||
resolution: {integrity: sha512-e1zGYRvbffpcHIrnuqT0Dh+gEJtDaxDSoG4JAIpq4oDFyooziLBIiYQv0GBT4FUAnUop5uZ1hiIAj7oAF6sOCA==}
|
||||
dependencies:
|
||||
tslib: 2.4.0
|
||||
dev: true
|
||||
|
||||
/tlds/1.231.0:
|
||||
resolution: {integrity: sha512-L7UQwueHSkGxZHQBXHVmXW64oi+uqNtzFt2x6Ssk7NVnpIbw16CRs4eb/jmKOZ9t2JnqZ/b3Cfvo97lnXqKrhw==}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user