locate-character
Advanced tools
Comparing version 2.0.5 to 3.0.0
{ | ||
"name": "locate-character", | ||
"version": "2.0.5", | ||
"version": "3.0.0", | ||
"description": "Get the line and column number of a specific character in a string", | ||
"main": "dist/locate-character.umd.js", | ||
"jsnext:main": "dist/locate-character.es.js", | ||
"module": "dist/locate-character.es.js", | ||
"type": "module", | ||
"types": "./types/index.d.ts", | ||
"exports": { | ||
"types": "./types/index.d.ts", | ||
"import": "./src/index.js" | ||
}, | ||
"scripts": { | ||
"test": "mocha", | ||
"pretest": "npm run build", | ||
"build": "rollup -c && tsc", | ||
"prepublish": "npm test" | ||
"test": "node test/test.js", | ||
"build": "dts-buddy", | ||
"prepublishOnly": "npm test && npm run build" | ||
}, | ||
"files": [ | ||
"dist/*.js", | ||
"dist/**/*.d.ts", | ||
"src", | ||
"types", | ||
"README.md" | ||
], | ||
"repository": "Rich-Harris/locate-character", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://gitlab.com/Rich-Harris/locate-character.git" | ||
}, | ||
"keywords": [ | ||
@@ -31,12 +36,10 @@ "string", | ||
"bugs": { | ||
"url": "https://github.com/Rich-Harris/locate-character/issues" | ||
"url": "https://gitlab.com/Rich-Harris/locate-character/issues" | ||
}, | ||
"homepage": "https://github.com/Rich-Harris/locate-character#README", | ||
"homepage": "https://gitlab.com/Rich-Harris/locate-character#README", | ||
"devDependencies": { | ||
"mocha": "^3.0.1", | ||
"rollup": "^0.34.7", | ||
"rollup-plugin-typescript": "^0.8.1", | ||
"typescript": "^2.3.2" | ||
"dts-buddy": "^0.1.6", | ||
"typescript": "^5.1.3" | ||
}, | ||
"types": "./dist/types/index.d.ts" | ||
} | ||
"packageManager": "pnpm@8.6.2" | ||
} |
@@ -9,3 +9,2 @@ # locate-character | ||
## Usage | ||
@@ -27,12 +26,12 @@ | ||
// Using a character index | ||
const index = sample.indexOf( 'fly' ); | ||
locate( sample, index ); | ||
const index = sample.indexOf('fly'); | ||
locate(sample, index); | ||
// -> { line: 0, column: 13, character: 13 } | ||
// Using the string itself | ||
locate( sample, 'fly' ); | ||
locate(sample, 'fly'); | ||
// -> { line: 0, column: 13, character: 13 } | ||
// Using the string with a start index | ||
locate( sample, 'fly', { startIndex: 14 }); | ||
locate(sample, 'fly', { startIndex: 14 }); | ||
// -> { line: 2, column: 9, character: 76 } | ||
@@ -46,11 +45,11 @@ ``` | ||
const locate = getLocator( sample ); | ||
const locate = getLocator(sample); | ||
let location = locate( 13 ); | ||
let location = locate(13); | ||
// -> { line: 0, column: 13, character: 13 } | ||
location = locate( 'fly', { startIndex: location.character + 1 }); | ||
location = locate('fly', { startIndex: location.character + 1 }); | ||
// -> { line: 2, column: 9, character: 76 } | ||
location = locate( 'fly', { startIndex: location.character + 1 }); | ||
location = locate('fly', { startIndex: location.character + 1 }); | ||
// -> { line: 3, column: 8, character: 104 } | ||
@@ -62,4 +61,4 @@ ``` | ||
```js | ||
getLocator( sample, { offsetLine: 1 }); | ||
locate( sample, { offsetLine: 1 }); | ||
getLocator(sample, { offsetLine: 1 }); | ||
locate(sample, { offsetLine: 1 }); | ||
``` | ||
@@ -69,5 +68,4 @@ | ||
## License | ||
MIT |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
2
0
Yes
5325
88
67
1