@symbo.ls/utils 0.0.10 → 0.0.12
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 +2 -2
- package/src/codify.js +17 -0
- package/src/index.js +1 -0
- package/src/scaling.js +0 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
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
|
-
"@
|
|
14
|
+
"@domql/utils": "latest"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@babel/core": "^7.11.5",
|
package/src/codify.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
export const stringifyProps = props => JSON.stringify(props, null, 2)
|
|
4
|
+
|
|
5
|
+
export const codify = (key, props) => ({
|
|
6
|
+
react: `import { ${key} } from 'smbls/react'
|
|
7
|
+
|
|
8
|
+
const props = ${stringifyProps(props)}
|
|
9
|
+
|
|
10
|
+
<${key} {...props} />`,
|
|
11
|
+
|
|
12
|
+
domql: `import { ${key} } from 'smbls/react'
|
|
13
|
+
|
|
14
|
+
const component = {
|
|
15
|
+
${key}: ${stringifyProps(props)}
|
|
16
|
+
}`
|
|
17
|
+
})
|
package/src/index.js
CHANGED
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)
|