Every line of 'split in node js' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
4 function split(nodes) { 5 var section = []; 6 7 var sections = _.reduce(nodes, function(sections, el) { 8 if(el.type === 'hr') { 9 sections.push(section); 10 section = []; 11 } else { 12 section.push(el); 13 } 14 15 return sections; 16 }, []) 17 // Add remaining nodes 18 .concat([section]) 19 // Exclude empty sections 20 .filter(_.negate(_.isEmpty)); 21 22 // Copy over links (kramed needs them) 23 sections.links = nodes.links || {}; 24 25 return sections; 26 }
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
27 function split(expressions) { 28 var tree = esprima.parse(expressions); 29 // console.dir(tree); 30 var exp = tree.body[0].expression; 31 if (Array.isArray(exp.expressions)) { 32 exp = exp.expressions; 33 } else { 34 exp = [exp]; 35 } 36 var results = exp.map(function (node) { 37 // console.log('node', node); 38 return generator.generate(node, options); 39 }); 40 return results; 41 }
114 export function splitAt(n, arr) { 115 return [arr.slice(0, n), arr.slice(n)]; 116 }