@symbo.ls/utils 0.0.9 → 0.0.11

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "src/index.js",
@@ -11,7 +11,7 @@
11
11
  "author": "",
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
- "@symbo.ls/scratch": "latest"
14
+ "@domql/utils": "latest"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@babel/core": "^7.11.5",
package/src/index.js CHANGED
@@ -28,9 +28,11 @@ export const toCamelCase = str => {
28
28
  }).replace(/\s+/g, '')
29
29
  }
30
30
 
31
- export const toTitleCase = str => {
32
- return str.replace(/(?:^\w|[A-Z]|\b\w)/g, word => word.toUpperCase()).replace(/\s+/g, '')
33
- }
31
+ export const toTitleCase = str => str.replace(
32
+ /\w\S*/g, txt => {
33
+ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
34
+ }
35
+ )
34
36
 
35
37
  export const toDashCase = val => val
36
38
  .replace(/[A-Z]/g, (match, offset) => (offset > 0 ? '-' : '') + match.toLowerCase())
@@ -38,5 +40,6 @@ export const toDashCase = val => val
38
40
 
39
41
 
40
42
  export const toDescriptionCase = str => {
41
- return str.replace(/(?:^\w|[A-Z]|\b\w)/g, word => word.toUpperCase()).replace(/\s+/g, ' ')
43
+ const result = str.replace(/([A-Z])/g, " $1")
44
+ return result.charAt(0).toUpperCase() + result.slice(1)
42
45
  }
package/src/scaling.js CHANGED
@@ -1,21 +1,7 @@
1
1
  'use strict'
2
2
 
3
- import { generateSequence } from '@symbo.ls/scratch'
4
-
5
3
  import { isObject, isArray } from '@domql/utils'
6
4
 
7
- export const sortSequence = (a, b) => a.index - b.index
8
-
9
- export const mapSequence = (state, sort) => {
10
- generateSequence(state)
11
- const { sequence } = state
12
- if (sort) {
13
- const values = Object.values(sequence)
14
- return values.sort(sort)
15
- }
16
- return sequence
17
- }
18
-
19
5
  export const findClosestNumber = (number, arr) => {
20
6
  return (isArray(arr) ? arr : Object.values(arr)).reduce((prev, curr) => {
21
7
  return (Math.abs(curr - number) < Math.abs(prev - number) ? curr : prev)