Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
23
Frontend-Learner/node_modules/to-valid-identifier/index.d.ts
generated
vendored
Normal file
23
Frontend-Learner/node_modules/to-valid-identifier/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
Convert a string to a valid [JavaScript identifier](https://developer.mozilla.org/docs/Glossary/Identifier).
|
||||
|
||||
Different inputs will always generate unique identifiers.
|
||||
|
||||
@example
|
||||
```
|
||||
import toValidIdentifier from 'to-valid-identifier';
|
||||
|
||||
toValidIdentifier('foo');
|
||||
//=> 'foo'
|
||||
|
||||
toValidIdentifier('foo-bar');
|
||||
//=> 'foo$j$bar'
|
||||
|
||||
toValidIdentifier('$');
|
||||
//=> '$a$'
|
||||
|
||||
toValidIdentifier('undefined');
|
||||
//=> '$_undefined$'
|
||||
```
|
||||
*/
|
||||
export default function toValidIdentifier(value: string): string;
|
||||
20
Frontend-Learner/node_modules/to-valid-identifier/index.js
generated
vendored
Normal file
20
Frontend-Learner/node_modules/to-valid-identifier/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import reservedIdentifiers_ from 'reserved-identifiers';
|
||||
import base62 from '@sindresorhus/base62';
|
||||
|
||||
const reservedIdentifiers = reservedIdentifiers_({includeGlobalProperties: true});
|
||||
|
||||
const encodeCodePoint = x => `$${base62.encodeInteger(x.codePointAt(0))}$`;
|
||||
|
||||
export default function toValidIdentifier(value) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new TypeError(`Expected a string, got \`${typeof value}\`.`);
|
||||
}
|
||||
|
||||
if (reservedIdentifiers.has(value)) {
|
||||
// We prefix with underscore to avoid any potential conflicts with the Base62 encoded string.
|
||||
return `$_${value}$`;
|
||||
}
|
||||
|
||||
return value.replaceAll(/(?<!^)\P{ID_Continue}/gu, encodeCodePoint)
|
||||
.replaceAll(/^[^_\p{ID_Start}]/gu, encodeCodePoint);
|
||||
}
|
||||
9
Frontend-Learner/node_modules/to-valid-identifier/license
generated
vendored
Normal file
9
Frontend-Learner/node_modules/to-valid-identifier/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
52
Frontend-Learner/node_modules/to-valid-identifier/package.json
generated
vendored
Normal file
52
Frontend-Learner/node_modules/to-valid-identifier/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"name": "to-valid-identifier",
|
||||
"version": "1.0.0",
|
||||
"description": "Convert a string to a valid JavaScript identifier",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/to-valid-identifier",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"valid",
|
||||
"identifier",
|
||||
"safe",
|
||||
"sanitize",
|
||||
"variable",
|
||||
"property",
|
||||
"ecmascript",
|
||||
"javascript",
|
||||
"js",
|
||||
"reserved",
|
||||
"keyword",
|
||||
"word",
|
||||
"property"
|
||||
],
|
||||
"dependencies": {
|
||||
"@sindresorhus/base62": "^1.0.0",
|
||||
"reserved-identifiers": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^6.4.1",
|
||||
"xo": "^1.2.3"
|
||||
}
|
||||
}
|
||||
47
Frontend-Learner/node_modules/to-valid-identifier/readme.md
generated
vendored
Normal file
47
Frontend-Learner/node_modules/to-valid-identifier/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# to-valid-identifier
|
||||
|
||||
> Convert a string to a valid [JavaScript identifier](https://developer.mozilla.org/docs/Glossary/Identifier)
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install to-valid-identifier
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import toValidIdentifier from 'to-valid-identifier';
|
||||
|
||||
toValidIdentifier('foo');
|
||||
//=> 'foo'
|
||||
|
||||
toValidIdentifier('foo-bar');
|
||||
//=> 'foo$j$bar'
|
||||
|
||||
toValidIdentifier('$');
|
||||
//=> '$a$'
|
||||
|
||||
toValidIdentifier('undefined');
|
||||
//=> '$_undefined$'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### toValidIdentifier(string)
|
||||
|
||||
Convert the given string to a valid JavaScript identifier.
|
||||
|
||||
Different inputs will always generate unique identifiers.
|
||||
|
||||
## Use cases
|
||||
|
||||
- **Code Generation:** Automate safe variable naming in scripts, avoiding syntax errors from invalid characters.
|
||||
- **Compilers/Transpilers:** Essential for non-JavaScript languages compiling to JavaScript, ensuring that identifiers are compliant.
|
||||
- **Dynamic Function Names:** Generate unique and valid function names from dynamic content such as user inputs or database fields.
|
||||
- **API Wrappers:** Convert API response properties into valid JavaScript object keys for easier access.
|
||||
- **Template Processing:** Ensure template placeholders are converted to valid JavaScript identifiers when replaced with dynamic values.
|
||||
|
||||
## Related
|
||||
|
||||
- [is-identifier](https://github.com/sindresorhus/is-identifier) - Check if a string is a valid JavaScript identifier
|
||||
Loading…
Add table
Add a link
Reference in a new issue