@lowdefy/operators-change-case 4.0.0-rc.9 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ /* eslint-disable import/namespace */ import { camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase } from 'change-case';
15
+ */ /* eslint-disable import/namespace */ import { camelCase, capitalCase, constantCase, dotCase, kebabCase, noCase, pascalCase, pascalSnakeCase, pathCase, sentenceCase, snakeCase, trainCase } from 'change-case';
16
16
  import { get, type } from '@lowdefy/helpers';
17
17
  import { runClass } from '@lowdefy/operators';
18
18
  const changeCase = {
@@ -20,43 +20,23 @@ const changeCase = {
20
20
  capitalCase,
21
21
  constantCase,
22
22
  dotCase,
23
- headerCase,
23
+ kebabCase,
24
24
  noCase,
25
- paramCase,
26
25
  pascalCase,
26
+ pascalSnakeCase,
27
27
  pathCase,
28
28
  sentenceCase,
29
- snakeCase
29
+ snakeCase,
30
+ trainCase
30
31
  };
31
- const prepRegex = (prop, location)=>{
32
- const regex = type.isString(prop) ? {
33
- pattern: prop
34
- } : prop;
35
- if (!type.isObject(regex)) {
36
- throw new Error(`Operator Error: regex must be string or an object. Received ${JSON.stringify(prop)} at ${location}.`);
37
- }
38
- try {
39
- return new RegExp(regex.pattern, regex.flags || 'gm');
40
- } catch (e) {
41
- throw new Error(`Operator Error: ${e.message}. Received: ${JSON.stringify(prop)} at ${location}.`);
42
- }
43
- };
44
- const prep = (args, { location })=>{
32
+ const prep = (args, { location })=>{
45
33
  const options = args[1];
46
34
  if (!type.isNone(options) && !type.isObject(options)) {
47
35
  throw new Error(`Operator Error: options must be an object. Received ${JSON.stringify(options)} at ${location}.`);
48
36
  }
49
- if (type.isObject(options)) {
50
- if (options.splitRegexp) {
51
- options.splitRegexp = prepRegex(options.splitRegexp, location);
52
- }
53
- if (options.stripRegexp) {
54
- options.stripRegexp = prepRegex(options.stripRegexp, location);
55
- }
56
- }
57
37
  return args;
58
38
  };
59
- const convertArray = ({ methodName , on , options })=>{
39
+ const convertArray = ({ methodName, on, options })=>{
60
40
  return on.map((item)=>{
61
41
  if (type.isString(item)) {
62
42
  return changeCase[methodName](item, options);
@@ -64,7 +44,7 @@ const convertArray = ({ methodName , on , options })=>{
64
44
  return item;
65
45
  });
66
46
  };
67
- const convertObject = ({ methodName , on , options })=>{
47
+ const convertObject = ({ methodName, on, options })=>{
68
48
  const result = {};
69
49
  const keyConverter = get(options, 'convertKeys') ? (key)=>changeCase[methodName](key, options) : (key)=>key;
70
50
  const valueConverter = get(options, 'convertValues', {
@@ -79,7 +59,7 @@ const convertObject = ({ methodName , on , options })=>{
79
59
  });
80
60
  return result;
81
61
  };
82
- const makeCaseChanger = ({ methodName })=>(on, options = {})=>{
62
+ const makeCaseChanger = ({ methodName })=>(on, options = {})=>{
83
63
  if (type.isString(on)) {
84
64
  return changeCase[methodName](on, options);
85
65
  }
@@ -117,7 +97,7 @@ Object.keys(changeCase).forEach((methodName)=>{
117
97
  prep
118
98
  };
119
99
  });
120
- function change_case({ params , location , methodName }) {
100
+ function change_case({ params, location, methodName }) {
121
101
  return runClass({
122
102
  functions,
123
103
  location,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/dist/types.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/operators-change-case",
3
- "version": "4.0.0-rc.9",
3
+ "version": "4.0.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -35,26 +35,24 @@
35
35
  "files": [
36
36
  "dist/*"
37
37
  ],
38
- "scripts": {
39
- "build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
40
- "clean": "rm -rf dist",
41
- "prepublishOnly": "pnpm build",
42
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
43
- },
44
38
  "dependencies": {
45
- "@lowdefy/helpers": "4.0.0-rc.9",
46
- "@lowdefy/operators": "4.0.0-rc.9",
47
- "change-case": "4.1.2"
39
+ "@lowdefy/helpers": "4.0.1",
40
+ "@lowdefy/operators": "4.0.1",
41
+ "change-case": "5.4.0"
48
42
  },
49
43
  "devDependencies": {
50
- "@swc/cli": "0.1.59",
51
- "@swc/core": "1.3.24",
52
- "@swc/jest": "0.2.24",
53
- "jest": "28.1.0",
54
- "jest-environment-jsdom": "28.1.0"
44
+ "@swc/cli": "0.1.63",
45
+ "@swc/core": "1.3.99",
46
+ "@swc/jest": "0.2.29",
47
+ "jest": "28.1.3",
48
+ "jest-environment-jsdom": "28.1.3"
55
49
  },
56
50
  "publishConfig": {
57
51
  "access": "public"
58
52
  },
59
- "gitHead": "d20e6ac424643feca527a732dc2b0710713c8243"
60
- }
53
+ "scripts": {
54
+ "build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
55
+ "clean": "rm -rf dist",
56
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
57
+ }
58
+ }