sql-love 0.9.1

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.
@@ -0,0 +1,29 @@
1
+ import substrCount from './substrCount';
2
+
3
+ describe('substrCount', function () {
4
+ it('should see 0', function () {
5
+ const haystack = 'hello world';
6
+ const needle = '?';
7
+ expect(substrCount(haystack, needle)).toBe(0);
8
+ });
9
+ it('should see 0 from empty string', function () {
10
+ const haystack = '';
11
+ const needle = '?';
12
+ expect(substrCount(haystack, needle)).toBe(0);
13
+ });
14
+ it('should see 1', function () {
15
+ const haystack = 'hello world?';
16
+ const needle = '?';
17
+ expect(substrCount(haystack, needle)).toBe(1);
18
+ });
19
+ it('should see 2 adjacent', function () {
20
+ const haystack = 'hello world??';
21
+ const needle = '?';
22
+ expect(substrCount(haystack, needle)).toBe(2);
23
+ });
24
+ it('should see 3', function () {
25
+ const haystack = '?hello world??';
26
+ const needle = '?';
27
+ expect(substrCount(haystack, needle)).toBe(3);
28
+ });
29
+ });
@@ -0,0 +1,9 @@
1
+ export default function substrCount(haystack: string, needle: string) {
2
+ let count = 0;
3
+ let pos = haystack.indexOf(needle);
4
+ while (pos !== -1) {
5
+ count += 1;
6
+ pos = haystack.indexOf(needle, pos + 1);
7
+ }
8
+ return count;
9
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "exclude": [
4
+ "node_modules",
5
+ "src/**/*.spec.ts",
6
+ "src/**/*.type.ts",
7
+ "src/**/*.interface.ts",
8
+ "src/mocks"
9
+ ]
10
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ESNext",
4
+ "target": "ESNext",
5
+ "outDir": "./dist",
6
+ "declaration": true,
7
+ "removeComments": false,
8
+ "noEmit": false,
9
+ "pretty": true,
10
+ "isolatedModules": true,
11
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
12
+ "sourceMap": false,
13
+ "skipLibCheck": true,
14
+ "moduleResolution": "node",
15
+ "allowSyntheticDefaultImports": true,
16
+ "types": ["vitest/globals"]
17
+ },
18
+ "include": [
19
+ "src/**/*.ts"
20
+ ],
21
+ "files": ["index.ts"]
22
+ }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ['**/*.spec.ts'],
6
+ globals: true,
7
+ },
8
+ });