refactor: limiting calls to $ function
Squashed commit of the following: commit c72da261cb5319d1eef207bff63b3c9cd49018df Author: Adam Pash <adam.pash@gmail.com> Date: Fri Sep 9 15:28:43 2016 -0400 refactor: limiting calls to $ function commit eeae88247d844d5c6acbc529dbc3ce4d14e04191 Author: Adam Pash <adam.pash@gmail.com> Date: Fri Sep 9 15:14:33 2016 -0400 refactor: convertNodeTo; requires a cheerio objectpull/1/head
parent
81e9e7a317
commit
47ac7e9803
@ -1,6 +1,6 @@
|
||||
// returns the score of a node based on
|
||||
// the node's score attribute
|
||||
// returns null if no score set
|
||||
export default function getScore(node, $) {
|
||||
return parseFloat(node.attr('score')) || null
|
||||
export default function getScore($node) {
|
||||
return parseFloat($node.attr('score')) || null
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
export default function setScore(node, $, score) {
|
||||
$(node).attr('score', score)
|
||||
return node
|
||||
export default function setScore($node, $, score) {
|
||||
$node.attr('score', score)
|
||||
return $node
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
export default function convertNodeTo(node, $, tag='p') {
|
||||
$(node).replaceWith(`<${tag}>${$(node).contents()}</${tag}>`)
|
||||
export default function convertNodeTo($node, $, tag='p') {
|
||||
$node.replaceWith(`<${tag}>${$node.contents()}</${tag}>`)
|
||||
return $
|
||||
}
|
||||
|
Loading…
Reference in New Issue