Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

between2

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

between2 - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

27

modules/index.js
'use strict';
var toFastProperties = require('to-fast-properties');
var reduce = require('lodash.reduce');
function strord(a, b) {

@@ -12,2 +15,7 @@ return a == b ? 0 : a < b ? -1 : 1;

var charsLength = chars.length;
var lookup = reduce(chars, function (accumulator, char, idx) {
accumulator[char] = idx;
return accumulator;
}, {});
toFastProperties(lookup);

@@ -27,7 +35,12 @@ var exports = between;

function randstr(l) {
// expect l >= 0
// expect l >= 0. if l
var str = '';
while (l--) {
str += chars[Math.floor(Math.random() * chars.length)];
while (l-- > 1) {
str += chars[Math.floor(Math.random() * charsLength)];
}
if (l == 0) {
str += chars[Math.floor(Math.random() * (charsLength - 2)) + 1];
}
return str;

@@ -59,8 +72,6 @@ }

while (i <= guard) {
// TODO: build lookup table
var _a = chars.indexOf(a[i]);
var _b = chars.indexOf(b[i]);
var _a = lookup[a[i]] || 0;
var _b = lookup[b[i]];
if (_a == -1) _a = 0;
if (_b == -1) _b = charsLength - 1;
if (_b == void 0) _b = charsLength - 1;

@@ -67,0 +78,0 @@ i++;

{
"name": "between2",
"version": "0.1.0",
"version": "0.1.1",
"description": "generate arbitary strings that sort between two strings. fork of between.",

@@ -30,3 +30,7 @@ "main": "modules/index.js",

"mocha": "^2.2.5"
},
"dependencies": {
"lodash.reduce": "^3.1.2",
"to-fast-properties": "^1.0.1"
}
}

@@ -43,10 +43,12 @@ # between2 [![Build Status](https://travis-ci.org/Dashed/between2.svg)](https://travis-ci.org/Dashed/between2)

### `strord(a)`
### `strord(a, b)`
TBA
Compares two strings, `a` and `b`, lexicographically. Returns `0` if `a == b`; `-1` if `a` is lexicographically less than `b`; `1` if `a` is lexicographically greater than `b`.
### `randstr(len)`
Generate random string with length `len`.
Generate random string with length `len` using `chars`. Expects `len >= 0`.
**NOTE:** The string's last character will never be either the `between.lo` character or the `between.hi` character for `chars` of size greater than two. This is intended so that this string, `a`, may be used as a reference point to generate strings that will be able to sort between `a` and any other string distinct from `a`. For `chars` of size 2, the `between.hi` character will be used.
### `inject(chars)`

@@ -56,2 +58,4 @@

**NOTE:** It's expected that `chars` is at least 2 distinct characters long.
### `between.lo` and `between.hi`

@@ -58,0 +62,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc