@parischap/effect-lib
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.strictEquals = exports.parameterNumber = exports.once = exports.isEquivalentTo = exports.flipDual = exports.fIfTrue = void 0; | ||
exports.strictEquals = exports.parameterNumber = exports.once = exports.isEquivalentTo = exports.flipDual = exports.fIfTrue = exports.applyAsMethod = void 0; | ||
var _effect = /*#__PURE__*/require("effect"); | ||
@@ -86,3 +86,11 @@ /** | ||
}; | ||
/** | ||
* Applies `f` to `o` | ||
* | ||
* @since 0.0.6 | ||
* @category Utils | ||
*/ | ||
exports.once = once; | ||
const applyAsMethod = o => self => self.call(o); | ||
exports.applyAsMethod = applyAsMethod; | ||
//# sourceMappingURL=Function.js.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.tryToStringToJson = exports.takeRightFrom = exports.takeRightBut = exports.takeLeftTo = exports.takeLeftBut = exports.stripRightOption = exports.stripRight = exports.stripLeftOption = exports.stripLeft = exports.splitAt = exports.searchRight = exports.searchAll = exports.search = exports.replaceBetween = exports.prepend = exports.match = exports.fromPrimitive = exports.fromNonNullablePrimitive = exports.count = exports.append = void 0; | ||
exports.tryToStringToJSON = exports.takeRightFrom = exports.takeRightBut = exports.takeLeftTo = exports.takeLeftBut = exports.stripRightOption = exports.stripRight = exports.stripLeftOption = exports.stripLeft = exports.splitAt = exports.searchRight = exports.searchAll = exports.search = exports.replaceBetween = exports.prepend = exports.match = exports.fromPrimitive = exports.fromNonNullablePrimitive = exports.count = exports.append = void 0; | ||
var _effect = /*#__PURE__*/require("effect"); | ||
@@ -160,10 +160,4 @@ var MFunction = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./Function.js")); | ||
exports.takeRightFrom = takeRightFrom; | ||
const tryToStringToJson = obj => { | ||
const tryApplyingFOnObj = f => { | ||
try { | ||
return (0, _effect.pipe)(f, _effect.Function.apply(obj), _effect.Option.liftPredicate(MTypes.isString)); | ||
} catch (_) { | ||
return _effect.Option.none(); | ||
} | ||
}; | ||
const tryToStringToJSON = obj => { | ||
const tryApplyingFOnObj = f => (0, _effect.pipe)(f, _effect.Option.liftPredicate((0, _effect.flow)(MFunction.parameterNumber, MFunction.strictEquals(0))), _effect.Option.map(MFunction.applyAsMethod(obj)), _effect.Option.filter(MTypes.isString)); | ||
return (0, _effect.pipe)(obj['toString'], /* eslint-disable-next-line @typescript-eslint/unbound-method */ | ||
@@ -178,3 +172,3 @@ _effect.Option.liftPredicate(_effect.Predicate.not(MFunction.strictEquals(Object.prototype.toString))), _effect.Option.flatMap(tryApplyingFOnObj), _effect.Option.orElse(() => (0, _effect.pipe)(obj['toJSON'], _effect.Option.liftPredicate(MTypes.isFunction), _effect.Option.flatMap(tryApplyingFOnObj)))); | ||
*/ | ||
exports.tryToStringToJson = tryToStringToJson; | ||
exports.tryToStringToJSON = tryToStringToJSON; | ||
const takeLeftBut = n => self => _effect.String.takeLeft(self, self.length - n); | ||
@@ -181,0 +175,0 @@ /** |
@@ -7,2 +7,3 @@ /** | ||
import { Function, Predicate } from 'effect'; | ||
import { LazyArg } from 'effect/Function'; | ||
import * as MTypes from './types.js'; | ||
@@ -63,2 +64,9 @@ /** | ||
export declare const once: <A>(f: Function.LazyArg<A>) => Function.LazyArg<A>; | ||
/** | ||
* Applies `f` to `o` | ||
* | ||
* @since 0.0.6 | ||
* @category Utils | ||
*/ | ||
export declare const applyAsMethod: (o: MTypes.AnyRecord) => <A>(self: LazyArg<A>) => A; | ||
//# sourceMappingURL=Function.d.ts.map |
@@ -70,3 +70,3 @@ /** | ||
*/ | ||
export declare const tryToStringToJson: (obj: MTypes.AnyRecord) => Option.Option<string>; | ||
export declare const tryToStringToJSON: (obj: MTypes.AnyRecord) => Option.Option<string>; | ||
/** | ||
@@ -73,0 +73,0 @@ * Takes all characters from `self` except the `n` last characters |
@@ -73,2 +73,9 @@ /** | ||
}; | ||
/** | ||
* Applies `f` to `o` | ||
* | ||
* @since 0.0.6 | ||
* @category Utils | ||
*/ | ||
export const applyAsMethod = o => self => self.call(o); | ||
//# sourceMappingURL=Function.js.map |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
import { Array, Function, Option, Predicate, String, Tuple, flow, pipe } from 'effect'; | ||
import { Array, Option, Predicate, String, Tuple, flow, pipe } from 'effect'; | ||
import * as MFunction from './Function.js'; | ||
@@ -121,10 +121,4 @@ import * as MMatch from './Match.js'; | ||
*/ | ||
export const tryToStringToJson = obj => { | ||
const tryApplyingFOnObj = f => { | ||
try { | ||
return pipe(f, Function.apply(obj), Option.liftPredicate(MTypes.isString)); | ||
} catch (_) { | ||
return Option.none(); | ||
} | ||
}; | ||
export const tryToStringToJSON = obj => { | ||
const tryApplyingFOnObj = f => pipe(f, Option.liftPredicate(flow(MFunction.parameterNumber, MFunction.strictEquals(0))), Option.map(MFunction.applyAsMethod(obj)), Option.filter(MTypes.isString)); | ||
return pipe(obj['toString'], /* eslint-disable-next-line @typescript-eslint/unbound-method */ | ||
@@ -131,0 +125,0 @@ Option.liftPredicate(Predicate.not(MFunction.strictEquals(Object.prototype.toString))), Option.flatMap(tryApplyingFOnObj), Option.orElse(() => pipe(obj['toJSON'], Option.liftPredicate(MTypes.isFunction), Option.flatMap(tryApplyingFOnObj)))); |
@@ -13,3 +13,3 @@ { | ||
}, | ||
"homepage": "https://github.com/parischap/effect-libs", | ||
"homepage": "https://github.com/parischap/effect-libs/tree/master/packages/effect-lib", | ||
"module": "./esm/index.js", | ||
@@ -38,5 +38,5 @@ "exports": { | ||
}, | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"main": "./cjs/index.js", | ||
"types": "./dts/index.d.ts" | ||
} |
@@ -11,2 +11,2 @@ ## EFFECT-LIB | ||
If you need to, take a look at the [documentation](https://parischap.github.io/effect-libs/docs/effect-lib). | ||
If you need to, take a look at the [API](https://parischap.github.io/effect-libs/docs/effect-lib). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
399087
7315
0