Socket
Socket
Sign inDemoInstall

estree-util-is-identifier-name

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

estree-util-is-identifier-name - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

lib/index.d.ts

19

index.d.ts

@@ -1,18 +0,1 @@

/**
* Checks if the given character code can start an identifier.
*
* @param {number} code
*/
export function start(code: number): boolean
/**
* Checks if the given character code can continue an identifier.
*
* @param {number} code
*/
export function cont(code: number): boolean
/**
* Checks if the given string is a valid identifier name.
*
* @param {string} name
*/
export function name(name: string): boolean
export {cont, name, start} from './lib/index.js'

@@ -1,38 +0,1 @@

import {start as startRe, cont as contRe} from './regex.js'
/**
* Checks if the given character code can start an identifier.
*
* @param {number} code
*/
// To do: support astrals.
export function start(code) {
return startRe.test(String.fromCharCode(code))
}
/**
* Checks if the given character code can continue an identifier.
*
* @param {number} code
*/
// To do: support astrals.
export function cont(code) {
const character = String.fromCharCode(code)
return startRe.test(character) || contRe.test(character)
}
/**
* Checks if the given string is a valid identifier name.
*
* @param {string} name
*/
export function name(name) {
let index = -1
while (++index < name.length) {
if (!(index ? cont : start)(name.charCodeAt(index))) return false
}
// `false` if `name` is empty.
return index > 0
}
export {cont, name, start} from './lib/index.js'
{
"name": "estree-util-is-identifier-name",
"version": "2.0.1",
"version": "2.1.0",
"description": "Check if something can be an ecmascript (javascript) identifier name",

@@ -30,30 +30,27 @@ "license": "MIT",

"files": [
"lib/",
"index.d.ts",
"index.js",
"regex.d.ts",
"regex.js"
"index.js"
],
"devDependencies": {
"@types/tape": "^4.0.0",
"@unicode/unicode-13.0.0": "^1.0.0",
"@types/node": "^18.0.0",
"@types/regenerate": "^1.0.0",
"@unicode/unicode-15.0.0": "^1.0.0",
"c8": "^7.6.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"regenerate": "^1.0.0",
"remark-cli": "^10.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"xo": "^0.50.0"
"xo": "^0.53.0"
},
"scripts": {
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
"generate": "node build",
"prepack": "npm run build && npm run format",
"generate": "node --conditions development build.js",
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test": "npm run generate && npm run build && npm run format && npm run test-coverage",
"prepack": "npm run build && npm run format"
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
"test": "npm run generate && npm run build && npm run format && npm run test-coverage"
},

@@ -60,0 +57,0 @@ "prettier": {

@@ -20,5 +20,5 @@ # estree-util-is-identifier-name

* [API](#api)
* [`name(value)`](#namevalue)
* [`cont(code)`](#contcode)
* [`name(name)`](#namename)
* [`start(code)`](#startcode)
* [`cont(code)`](#contcode)
* [Types](#types)

@@ -43,3 +43,3 @@ * [Compatibility](#compatibility)

This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [npm][]:
In Node.js (version 14.14+ and 16.0+), install with [npm][]:

@@ -67,3 +67,3 @@ ```sh

```js
import {name, start, cont} from 'estree-util-is-identifier-name'
import {cont, name, start} from 'estree-util-is-identifier-name'

@@ -80,19 +80,45 @@ name('$something69') // => true

This package exports the identifiers `name`, `start`, and `cont`.
This package exports the identifiers [`cont`][cont], [`name`][name], and
[`start`][start].
There is no default export.
### `name(value)`
### `cont(code)`
Checks if `value` (`string`) is a valid identifier name (`boolean`).
Checks if the given character code can continue an identifier.
###### Parameters
* `code` (`number`)
— character code to check
###### Returns
Whether `code` can continue an identifier (`boolean`).
### `name(name)`
Checks if the given value is a valid identifier name.
###### Parameters
* `name` (`string`)
— identifier to check
###### Returns
Whether `name` can be an identifier (`boolean`).
### `start(code)`
Checks if the given character code (`number`) can start an identifier
(`boolean`).
Checks if the given character code can start an identifier.
### `cont(code)`
###### Parameters
Checks if the given character code (`number`) can continue an identifier
(`boolean`).
* `code` (`number`)
— character code to check
###### Returns
Whether `code` can start an identifier (`boolean`).
## Types

@@ -107,3 +133,3 @@

versions of Node.js.
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
As of now, that is Node.js 14.14+ and 16.0+.
Our projects sometimes work with older versions, but this is not guaranteed.

@@ -179,1 +205,7 @@

[estree]: https://github.com/estree/estree
[cont]: #contcode
[name]: #namename
[start]: #startcode
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc