Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
nlcst-is-literal
Advanced tools
Readme
nlcst utility to check if a node is meant literally.
This utility can check if a node is meant literally.
This package is a tiny utility that helps when dealing with words. It’s useful if a tool wants to exclude values that are possibly void of meaning. For example, a spell-checker could exclude these literal words, thus not warning about “monsieur”.
This package is ESM only. In Node.js (version 16+), install with npm:
npm install nlcst-is-literal
In Deno with esm.sh
:
import {isLiteral} from 'https://esm.sh/nlcst-is-literal@3'
In browsers with esm.sh
:
<script type="module">
import {isLiteral} from 'https://esm.sh/nlcst-is-literal@3?bundle'
</script>
Say our document example.txt
contains:
The word “foo” is meant as a literal.
The word «bar» is meant as a literal.
The word (baz) is meant as a literal.
The word, qux, is meant as a literal.
The word — quux — is meant as a literal.
…and our module example.js
looks as follows:
import {read} from 'to-vfile'
import {ParseEnglish} from 'parse-english'
import {visit} from 'unist-util-visit'
import {toString} from 'nlcst-to-string'
import {isLiteral} from 'nlcst-is-literal'
const file = await read('example.txt')
const tree = new ParseEnglish().parse(String(file))
visit(tree, 'WordNode', function (node, index, parent) {
if (isLiteral(parent, index)) {
console.log(toString(node))
}
})
…now running node example.js
yields:
foo
bar
baz
qux
quux
This package exports the identifier isLiteral
.
There is no default export.
isLiteral(parent, index|child)
Check if the child in parent
at index
is enclosed by matching delimiters.
For example, foo
is literal in the following samples:
Foo - is meant as a literal.
Meant as a literal is - foo.
The word “foo” is meant as a literal.
parent
(Node
)
— parent nodeindex
(number
)
— index of child in parentchild
(Node
)
— child node of parentWhether the child is a literal (boolean
).
This package is fully typed with TypeScript. It exports no additional types.
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, nlcst-is-literal@^3
,
compatible with Node.js 16.
nlcst-normalize
— normalize a word for easier comparisonnlcst-search
— search for patternsSee contributing.md
in syntax-tree/.github
for
ways to get started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
FAQs
nlcst utility to check whether a node is meant literally
We found that nlcst-is-literal demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).