0.2.4 • Published 5 years ago

@cat5th/get-comments v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

get-comments

npm version coverage npm downloads Build Status

A script that gets document comments

Installation

yarn add @cat5th/get-comments

or

npm i @cat5th/get-comments

Usage

<!DOCTYPE HTML>
<html>
<head></head>
<body>
  <!--hello-->
  <!--hello2-->  
</body>
</html>
import { getComment, getComments } from '@cat5th/get-comments'

// get a single element
getComment('hello') // => <!--hello-->

// get comments
getComments('hello') // => <!--hello-->,<!--hello2-->

// by function
getComments((elem) => {
  // you can filter elem here 
  return true
}) // => <!--hello-->,<!--hello2-->

// or regexp
getComment(/hello/)

// or undefined means all comments
getComments(undefined)
getComments()

// the 2nd param is used to limit the lookup context
getComments(undefined, document.querySelector('div'))