Skip to content

Matt-Esch/jsonml-walk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsonml-walk

Walk a loose jsonml tree with hooks

Example

var walk = require("jsonml-walk")
var console = require("console")

// Log all tag names pre-order
walk(["div", [
    ["p", [
        ["span", ["hello"]],
        ["b", ["world"]]
    ]]
]], {
    before: function(node, opts) {
        console.log(node.head)
    }
})
// -> div
// -> p
// -> span
// -> b

// Log all text nodes pre-order
walk(["div", [
    ["p", [
        ["span", ["hello"]],
        ["b", ["world"]]
    ]]
]], {
    textNode: function(text, opts) {
        console.log(text)
    }
})
// -> hello
// -> world

Installation

npm install jsonml-walk

Contributors

  • Matt-Esch

MIT Licenced

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published