Skip to content

Commit

Permalink
Fix #397: str/index-of + str/last-index-of
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Dec 16, 2023
1 parent 7398632 commit a16d829
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/squint/string.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_", "destructuredArrayIgnorePattern": "^_"}]*/

import { iterable, string_QMARK_ } from './core.js';
import { iterable, neg_QMARK_, string_QMARK_ } from './core.js';

export function blank_QMARK_(s) {
if (!s) return true;
Expand Down Expand Up @@ -110,3 +110,19 @@ export function replace(s, match, replacement) {
export function split_lines(s) {
return split(s, /\n|\r\n/);
}

export function index_of(s, value, from) {
const res = s.indexOf(value, from);
if (res < 0) {
return null;
}
return res;
}

export function last_index_of(s, value, from) {
const res = s.lastIndexOf(value, from);
if (res < 0) {
return null;
}
return res;
}

0 comments on commit a16d829

Please sign in to comment.