UNPKG
decap-cms-core
Version:
beta (3.4.3-beta.0)
latest (3.9.0)
3.9.0
3.8.1
3.8.0
3.7.1
3.7.0
3.6.3
3.6.2
3.6.1
3.6.0
3.5.0
3.4.3-beta.0
3.4.2
3.4.1
3.4.0
3.3.7
3.3.6
3.3.5
3.3.4
3.3.3
3.3.2
3.3.1
3.3.0
3.3.0-beta.4
3.3.0-beta.3
3.3.0-beta.2
3.3.0-beta.1
3.3.0-beta.0
3.2.8
3.2.6
3.2.5
3.2.4
3.2.3
3.2.2
3.2.1
3.2.0
3.1.1
3.1.0
3.0.0
2.56.0-beta.1
Decap CMS core application, see decap-cms package for the main distribution.
decap-cms-core
/
src
/
lib
/
textHelper.js
12 lines
(9 loc)
•
274 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
export function stringToRGB(
str
) {
if
(!
str
)
return
'000000'
; let
hash
=
0
;
for
(let i =
0
; i <
str
.length; i++) {
hash
=
str
.charCodeAt(i) + ((
hash
<<
5
) -
hash
); } const c = (
hash
&
0x00ffffff
).toString(
16
).toUpperCase();
return
`
00000
${c}`.
slice
(-
6
); }