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

space-lift

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

space-lift - npm Package Compare versions

Comparing version 0.8.4 to 0.8.5

commonjs/iterator.d.ts

2

commonjs/lift.d.ts

@@ -11,3 +11,3 @@ import { Wrapper, ArrayOpsConstructor, ArrayOps as IArrayOps, ObjectOpsConstructor, ObjectOps as IObjectOps, NumberOpsConstructor, NumberOps as INumberOps, StringOpsConstructor, StringOps as IStringOps, DateOpsConstructor, DateOps as IDateOps } from '../wrapper';

/** Wraps an Array to provide a richer API. Unwrap with .value() **/
<T>(obj: T[]): ArrayOps<T>;
<T>(obj: ReadonlyArray<T>): ArrayOps<T>;
/** Wraps a plain Object to provide a richer API. Unwrap with .value() **/

@@ -14,0 +14,0 @@ <T extends {}>(obj: T): ObjectOps<T>;

"use strict";
exports.__esModule = true;
var iterator_1 = require("./iterator");
var lift = function (obj) {

@@ -30,5 +31,17 @@ if (obj instanceof Array)

}());
Ops.prototype[iterator_1.iteratorSymbol] = iterator_1.singleValueIterator(function (self) { return self._value; });
return Ops;
}
exports.ArrayOps = makeOps();
exports.ArrayOps.prototype[iterator_1.iteratorSymbol] = function () {
var i = 0;
var self = this;
return {
next: function () {
return i < self._value.length
? { value: self._value[i++], done: false }
: { done: true };
}
};
};
exports.ObjectOps = makeOps();

@@ -35,0 +48,0 @@ exports.NumberOps = makeOps();

import { Wrapper, ArrayOps } from '../lift';
import { Result } from '../result';
export interface Option<A> {
export interface Option<A> extends Iterable<A> {
/**

@@ -41,2 +41,7 @@ * Returns the value contained in this Option.

*/
filter<B extends A>(fn: (a: A) => a is B): Option<B>;
/**
* If this Option is a Some and the predicate returns true, keep that Some.
* In all other cases, return None.
*/
filter(fn: (a: A) => boolean): Option<A>;

@@ -59,2 +64,6 @@ /**

*/
exists<B extends A>(predicate: (a: A) => a is B): this is Option<B>;
/**
* Returns whether this option is a Some with a value satisfying the predicate.
*/
exists(predicate: (a: A) => boolean): boolean;

@@ -61,0 +70,0 @@ /**

"use strict";
exports.__esModule = true;
var _a;
var lift_1 = require("../lift");
var result_1 = require("../result");
var iterator_1 = require("../iterator");
// The Option factory / static object

@@ -45,2 +47,7 @@ var OptionObject = function (value) {

self.toJSON = function () { return null; };
self[iterator_1.iteratorSymbol] = function () {
return {
next: function () { return { done: true }; }
};
};
return self;

@@ -51,51 +58,53 @@ }

}
_Some.prototype = {
type: 'some',
Option: OptionObject,
get: function () {
return this.value;
_Some.prototype = (_a = {
type: 'some',
Option: OptionObject,
get: function () {
return this.value;
},
isDefined: function () {
return true;
},
forEach: function (fn) {
fn(this.value);
},
map: function (fn) {
return exports.Option(lift_1.getValue(fn(this.value)));
},
flatMap: function (fn) {
return fn(this.value);
},
filter: function (fn) {
return fn(this.value) ? this : exports.None;
},
fold: function (ifEmpty, ifDefined) {
return ifDefined(this.value);
},
orElse: function () {
return this;
},
getOrElse: function () {
return this.value;
},
contains: function (value) {
return this.value === value;
},
exists: function (predicate) {
return predicate(this.value);
},
toArray: function () {
return lift_1["default"]([this.value]);
},
toResult: function () {
return result_1.Ok(this.value);
},
toString: function () {
return "Some(" + this.value + ")";
},
toJSON: function () {
return this.value.toJSON ? this.value.toJSON() : this.value;
}
},
isDefined: function () {
return true;
},
forEach: function (fn) {
fn(this.value);
},
map: function (fn) {
return exports.Option(lift_1.getValue(fn(this.value)));
},
flatMap: function (fn) {
return fn(this.value);
},
filter: function (fn) {
return fn(this.value) ? this : exports.None;
},
fold: function (ifEmpty, ifDefined) {
return ifDefined(this.value);
},
orElse: function () {
return this;
},
getOrElse: function () {
return this.value;
},
contains: function (value) {
return this.value === value;
},
exists: function (predicate) {
return predicate(this.value);
},
toArray: function () {
return lift_1["default"]([this.value]);
},
toResult: function () {
return result_1.Ok(this.value);
},
toString: function () {
return "Some(" + this.value + ")";
},
toJSON: function () {
return this.value.toJSON ? this.value.toJSON() : this.value;
}
};
_a[iterator_1.iteratorSymbol] = iterator_1.singleValueIterator(function (self) { return self.value; }),
_a);
function isDef(value) {

@@ -102,0 +111,0 @@ return value !== null && value !== undefined;

@@ -11,3 +11,3 @@ import { Wrapper, ArrayOpsConstructor, ArrayOps as IArrayOps, ObjectOpsConstructor, ObjectOps as IObjectOps, NumberOpsConstructor, NumberOps as INumberOps, StringOpsConstructor, StringOps as IStringOps, DateOpsConstructor, DateOps as IDateOps } from '../wrapper';

/** Wraps an Array to provide a richer API. Unwrap with .value() **/
<T>(obj: T[]): ArrayOps<T>;
<T>(obj: ReadonlyArray<T>): ArrayOps<T>;
/** Wraps a plain Object to provide a richer API. Unwrap with .value() **/

@@ -14,0 +14,0 @@ <T extends {}>(obj: T): ObjectOps<T>;

@@ -0,1 +1,2 @@

import { iteratorSymbol, singleValueIterator } from './iterator';
var lift = function (obj) {

@@ -27,5 +28,17 @@ if (obj instanceof Array)

}());
Ops.prototype[iteratorSymbol] = singleValueIterator(function (self) { return self._value; });
return Ops;
}
export var ArrayOps = makeOps();
ArrayOps.prototype[iteratorSymbol] = function () {
var i = 0;
var self = this;
return {
next: function () {
return i < self._value.length
? { value: self._value[i++], done: false }
: { done: true };
}
};
};
export var ObjectOps = makeOps();

@@ -32,0 +45,0 @@ export var NumberOps = makeOps();

import { Wrapper, ArrayOps } from '../lift';
import { Result } from '../result';
export interface Option<A> {
export interface Option<A> extends Iterable<A> {
/**

@@ -41,2 +41,7 @@ * Returns the value contained in this Option.

*/
filter<B extends A>(fn: (a: A) => a is B): Option<B>;
/**
* If this Option is a Some and the predicate returns true, keep that Some.
* In all other cases, return None.
*/
filter(fn: (a: A) => boolean): Option<A>;

@@ -59,2 +64,6 @@ /**

*/
exists<B extends A>(predicate: (a: A) => a is B): this is Option<B>;
/**
* Returns whether this option is a Some with a value satisfying the predicate.
*/
exists(predicate: (a: A) => boolean): boolean;

@@ -61,0 +70,0 @@ /**

@@ -0,3 +1,5 @@

var _a;
import lift, { getValue } from '../lift';
import { Err, Ok } from '../result';
import { iteratorSymbol, singleValueIterator } from '../iterator';
// The Option factory / static object

@@ -43,2 +45,7 @@ var OptionObject = function (value) {

self.toJSON = function () { return null; };
self[iteratorSymbol] = function () {
return {
next: function () { return { done: true }; }
};
};
return self;

@@ -49,51 +56,53 @@ }

}
_Some.prototype = {
type: 'some',
Option: OptionObject,
get: function () {
return this.value;
_Some.prototype = (_a = {
type: 'some',
Option: OptionObject,
get: function () {
return this.value;
},
isDefined: function () {
return true;
},
forEach: function (fn) {
fn(this.value);
},
map: function (fn) {
return Option(getValue(fn(this.value)));
},
flatMap: function (fn) {
return fn(this.value);
},
filter: function (fn) {
return fn(this.value) ? this : None;
},
fold: function (ifEmpty, ifDefined) {
return ifDefined(this.value);
},
orElse: function () {
return this;
},
getOrElse: function () {
return this.value;
},
contains: function (value) {
return this.value === value;
},
exists: function (predicate) {
return predicate(this.value);
},
toArray: function () {
return lift([this.value]);
},
toResult: function () {
return Ok(this.value);
},
toString: function () {
return "Some(" + this.value + ")";
},
toJSON: function () {
return this.value.toJSON ? this.value.toJSON() : this.value;
}
},
isDefined: function () {
return true;
},
forEach: function (fn) {
fn(this.value);
},
map: function (fn) {
return Option(getValue(fn(this.value)));
},
flatMap: function (fn) {
return fn(this.value);
},
filter: function (fn) {
return fn(this.value) ? this : None;
},
fold: function (ifEmpty, ifDefined) {
return ifDefined(this.value);
},
orElse: function () {
return this;
},
getOrElse: function () {
return this.value;
},
contains: function (value) {
return this.value === value;
},
exists: function (predicate) {
return predicate(this.value);
},
toArray: function () {
return lift([this.value]);
},
toResult: function () {
return Ok(this.value);
},
toString: function () {
return "Some(" + this.value + ")";
},
toJSON: function () {
return this.value.toJSON ? this.value.toJSON() : this.value;
}
};
_a[iteratorSymbol] = singleValueIterator(function (self) { return self.value; }),
_a);
function isDef(value) {

@@ -100,0 +109,0 @@ return value !== null && value !== undefined;

{
"name": "space-lift",
"version": "0.8.4",
"version": "0.8.5",
"description": "Idiomatic TS array, object utils, Option, Result monads",

@@ -18,5 +18,5 @@

"build": "npm run build-commonjs && npm run build-es",
"build-es": "tsc src/**/*.ts src/*.ts --lib 'es5,es2015.core' --outDir ./es --declaration --strict --suppressImplicitAnyIndexErrors --module es6 --moduleResolution node",
"build-commonjs": "tsc src/**/*.ts src/*.ts --lib 'es5,es2015.core' --outDir ./commonjs --declaration --strict --suppressImplicitAnyIndexErrors",
"pretest": "npm run build && tsc --lib 'es5,es2015.core' test/expect.d.ts test/mocha.d.ts test/global.d.ts test/test.ts test/option.ts test/result.ts --outDir ./test --noImplicitAny --strictNullChecks",
"build-es": "tsc src/**/*.ts src/*.ts --lib 'es5,es2015.core,es2015.iterable' --outDir ./es --declaration --strict --suppressImplicitAnyIndexErrors --module es6 --moduleResolution node",
"build-commonjs": "tsc src/**/*.ts src/*.ts --lib 'es5,es2015.core,es2015.iterable' --outDir ./commonjs --declaration --strict --suppressImplicitAnyIndexErrors",
"pretest": "npm run build && tsc --lib 'es5,es2015.core,es2015.iterable' test/expect.d.ts test/mocha.d.ts test/global.d.ts test/test.ts test/option.ts test/result.ts --outDir ./test --noImplicitAny --strictNullChecks --downlevelIteration",
"test": "mocha test/test.js && mocha --ui tdd test/option.js && mocha --ui tdd test/result.js",

@@ -23,0 +23,0 @@ "prepublish": "npm run build"

@@ -12,7 +12,7 @@

export interface ArrayOpsConstructor {
new<A>(value: A[]): ArrayOps<A>
new<A>(value: ReadonlyArray<A>): ArrayOps<A>
readonly prototype: ArrayOps<any>
}
export interface ArrayOps<A> extends Wrapper<A[]> {}
export interface ArrayOps<A> extends Wrapper<A[]>, Iterable<A> {}

@@ -25,3 +25,3 @@

export interface ObjectOps<A> extends Wrapper<A> {}
export interface ObjectOps<A> extends Wrapper<A>, Iterable<A> {}

@@ -34,3 +34,3 @@

export interface NumberOps extends Wrapper<number> {}
export interface NumberOps extends Wrapper<number>, Iterable<number> {}

@@ -43,13 +43,5 @@

export interface StringOps extends Wrapper<string> {}
export interface StringOps extends Wrapper<string>, Iterable<string> {}
export interface BoolOpsConstructor {
new(value: boolean): BoolOps
readonly prototype: BoolOps
}
export interface BoolOps extends Wrapper<boolean> {}
export interface DateOpsConstructor {

@@ -60,4 +52,4 @@ new(value: Date): DateOps

export interface DateOps extends Wrapper<Date> {}
export interface DateOps extends Wrapper<Date>, Iterable<Date> {}
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