find-cli 1.6.3 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/occurrence.js CHANGED
@@ -27,9 +27,8 @@ class Occurrence {
27
27
  return occurrence;
28
28
  }
29
29
 
30
- static fromIndexStringAndOffset(index, string, offset) {
31
- const length = string.length,
32
- start = index + offset,
30
+ static fromIndexLengthAndOffset(index, length, offset) {
31
+ const start = index + offset,
33
32
  end = start + length,
34
33
  occurrence = new Occurrence(start, end);
35
34
 
@@ -4,7 +4,7 @@ const Occurrence = require("../occurrence");
4
4
 
5
5
  const { STRING_TYPE } = require("../types"),
6
6
  { isStringStringLiteral } = require("../utilities/literal"),
7
- { addDoubleQuotes, removeDoubleQuotes, addTrailingForwardSlash, removeTrailingForwardSlash } = require("../utilities/string");
7
+ { removeDoubleQuotes, addTrailingForwardSlash, removeTrailingForwardSlash } = require("../utilities/string");
8
8
 
9
9
  class StringRule {
10
10
  constructor(string) {
@@ -32,10 +32,11 @@ class StringRule {
32
32
 
33
33
  let offset = 0,
34
34
  string = content, ///
35
- index = string.indexOf(this.string);
35
+ index = string.indexOf(this.string),
36
+ length = this.string.length;
36
37
 
37
38
  while (index !== -1) {
38
- const occurrence = Occurrence.fromIndexStringAndOffset(index, string, offset),
39
+ const occurrence = Occurrence.fromIndexLengthAndOffset(index, length, offset),
39
40
  end = occurrence.getEnd(),
40
41
  start = end; ///
41
42
 
@@ -45,19 +46,15 @@ class StringRule {
45
46
 
46
47
  occurrences.push(occurrence);
47
48
 
48
- index = string.match(this.regExp);
49
+ index = string.indexOf(this.string);
49
50
  }
50
51
 
51
52
  return occurrences;
52
53
  }
53
54
 
54
55
  match(string) {
55
- this.string = removeDoubleQuotes(this.string); ///
56
-
57
56
  const matches = (this.string === string);
58
57
 
59
- this.string = addDoubleQuotes(this.string); ///
60
-
61
58
  return matches;
62
59
  }
63
60
 
@@ -107,8 +104,6 @@ function stringFromStringAndDirectory(string, directory) {
107
104
  if (directory) {
108
105
  string = addTrailingForwardSlash(string); ///
109
106
  }
110
-
111
- string = addDoubleQuotes(string); ///
112
107
  } else {
113
108
  string = null;
114
109
  }
@@ -6,8 +6,6 @@ function addAnchors(string) { return `^${string}$`; }
6
6
 
7
7
  function removeAnchors(string) { return string.replace(/(^\^|\$$)/g, EMPTY_STRING); }
8
8
 
9
- function addDoubleQuotes(string) { return `"${string}"`; }
10
-
11
9
  function addForwardSlashes(string) { return `/${string}/`; }
12
10
 
13
11
  function removeDoubleQuotes(string) { return string.replace(/(^"|"$)/g, EMPTY_STRING); }
@@ -25,7 +23,6 @@ function removeTrailingEscapedForwardSlash(string) { return string.replace(/(\\\
25
23
  module.exports = {
26
24
  addAnchors,
27
25
  removeAnchors,
28
- addDoubleQuotes,
29
26
  addForwardSlashes,
30
27
  removeDoubleQuotes,
31
28
  removeForwardSlashes,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "find-cli",
3
3
  "author": "James Smith",
4
- "version": "1.6.3",
4
+ "version": "1.6.4",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/find-cli",
7
7
  "description": "An alternative to grep.",