stringx

Yet another string utility dealing with startsWith, endsWith and etc.

Usage no npm install needed!

<script type="module">
  import stringx from 'https://cdn.skypack.dev/stringx';
</script>

README

stringx

Yet another string utility dealing with startsWith, endsWith and etc.

Installation

npm install stringx

Usage

var stringx = require('./stringx');

describe('stringx Suite', function () {
    beforeEach(function () {
    });
    afterEach(function () {
    });

    it('should work: startsWith', function () {
        expect(stringx.startsWith('abcdefg', 'a')).toBeTruthy();
        expect(stringx.startsWith('abcdefg', 'ab')).toBeTruthy();
        expect(stringx.startsWith('abcdefg', '')).toBeTruthy();
        expect(stringx.startsWith('abcdefg', 'x')).toBeFalsy();
        expect(stringx.startsWith('abcdefg', 'g')).toBeFalsy();
    });
    it('should work: endsWith', function () {
        expect(stringx.endsWith('abcdefg', 'g')).toBeTruthy();
        expect(stringx.endsWith('abcdefg', 'fg')).toBeTruthy();
        expect(stringx.endsWith('abcdefg', '')).toBeTruthy();
        expect(stringx.endsWith('abcdefg', 'x')).toBeFalsy();
        expect(stringx.endsWith('abcdefg', 'a')).toBeFalsy();
    });
});