Socket
Socket
Sign inDemoInstall

locate-character

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.5 to 3.0.0

src/index.js

41

package.json
{
"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
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc