Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
T
topjs3-demos
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leon Li
topjs3-demos
Commits
a7e7600a
Commit
a7e7600a
authored
Jul 26, 2020
by
l2m2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upload
parent
8864a803
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
er.js
src/er.js
+38
-0
No files found.
src/er.js
0 → 100644
View file @
a7e7600a
var
_
=
require
(
"lodash"
);
var
getEr
=
function
(
iDielectricConst
,
iImpedanceHz
)
{
iDielectricConst
=
_
.
toString
(
iDielectricConst
);
if
(
iDielectricConst
==
''
)
{
return
0
;
}
if
(
!
/=/
.
test
(
iDielectricConst
))
{
return
_
.
toNumber
(
iDielectricConst
);
}
var
_hz
=
function
(
v
)
{
if
(
/g/i
.
test
(
v
))
{
return
_
.
toNumber
(
v
.
replace
(
/g/i
,
''
))
*
1000
*
1000
;
}
else
if
(
/m/i
.
test
(
v
))
{
v
return
_
.
toNumber
(
v
.
replace
(
/m/i
,
''
))
*
1000
;
}
else
{
return
_
.
toNumber
(
v
);
}
};
var
options
=
iDielectricConst
.
split
(
';'
);
return
_
.
chain
(
options
)
.
filter
(
function
(
item
){
return
item
.
split
(
'='
).
length
==
2
;
})
.
reduce
(
function
(
prev
,
curr
)
{
var
temp
=
curr
.
replace
(
/^
\s
+|
\s
+$/g
,
''
).
split
(
'='
);
var
diff
=
Math
.
abs
(
_hz
(
iImpedanceHz
)
-
_hz
(
temp
[
0
]));
if
(
prev
.
diff
==
-
1
||
diff
<
prev
.
diff
)
{
prev
.
diff
=
diff
;
prev
.
value
=
_
.
toNumber
(
temp
[
1
]);
}
return
prev
;
},
{
diff
:
-
1
})
.
value
().
value
;
}
var
r
=
getEr
(
"1G=4.15;2G=4.5"
,
"1.49G"
);
print
(
"r = "
,
r
);
r
=
getEr
(
"4.3"
,
"2G"
);
print
(
"r = "
,
r
);
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment