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

@flock/kotlin-ts

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flock/kotlin-ts - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

6

collection/Array.js

@@ -7,8 +7,8 @@ "use strict";

*/
const sum = (self) => self.reduce((prev, cur) => prev + cur, 0);
exports.sum = sum;
const sum_1 = (self) => self.reduce((prev, cur) => prev + cur, 0);
exports.sum = sum_1;
/**
* @tsplus fluent Array average
*/
const average = (self) => sum(self) / self.length;
const average = (self) => sum_1(self) / self.length;
exports.average = average;

@@ -15,0 +15,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tsplus_module_1 = require("./Array");
const tsplus_module_2 = require("./Iterable");
describe("Array", () => {

@@ -10,3 +11,3 @@ const numbers = [1, 2, 3];

test("average", () => {
expect(tsplus_module_1.average(numbers)).toMatchInlineSnapshot(`2`);
expect(tsplus_module_2.average(numbers)).toMatchInlineSnapshot(`2`);
});

@@ -13,0 +14,0 @@ test("distinct", () => {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withIndex = exports.zip = exports.indexOf_ = exports.isEmpty = exports.first = exports.indexOf = exports.find = exports.elementAt = exports.contains = exports.iterator = exports.toArray = exports.map = exports.average = exports.associateWithTo = exports.associateWith = exports.associateTo = exports.associateByTo_ = exports.associateByTo = exports.associateBy_ = exports.associateBy = exports.associate = exports.asSequence = exports.asIterable = exports.any_ = exports.any = exports.all = exports.naturals = exports.iterableOf = exports.createIterable = exports.Iterable = void 0;
exports.withIndex = exports.zip = exports.indexOf_ = exports.isEmpty = exports.first = exports.indexOf = exports.elementAt = exports.contains = exports.iterator = exports.toArray = exports.map = exports.average = exports.associateWithTo = exports.associateWith = exports.associateTo = exports.associateByTo_ = exports.associateByTo = exports.associateBy_ = exports.associateBy = exports.associate = exports.asSequence = exports.asIterable = exports.any_ = exports.any = exports.all = exports.naturals = exports.iterableOf = exports.Iterable = exports.find = exports.createIterable = void 0;
const tsplus_module_1 = require("./Sequence");
exports.createIterable = createIterable_1;
exports.find = find_1;
// From: https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/common/src/generated/_Collections.kt

@@ -9,3 +11,3 @@ const utils_js_1 = require("../utils.js");

exports.Iterable = {};
function createIterable(iteratorFactory) {
function createIterable_1(iteratorFactory) {
if (iteratorFactory.length === 0)

@@ -15,3 +17,2 @@ return { [Symbol.iterator]: iteratorFactory };

}
exports.createIterable = createIterable;
/**

@@ -21,3 +22,3 @@ * @tsplus static IterableOps of

const iterableOf = (...elements) => ({
[Symbol.iterator]: () => iterator(elements),
[Symbol.iterator]: () => iterator_1(elements),
});

@@ -28,6 +29,7 @@ exports.iterableOf = iterableOf;

*/
exports.naturals = createIterable(() => {
const naturals_1 = createIterable_1(() => {
let n = 0;
return { next: () => ({ value: n++, done: false }) };
});
exports.naturals = naturals_1;
/**

@@ -62,3 +64,3 @@ * Returns `true` if all elements match the given [predicate].

*/
const any_ = (self) => !iterator(self).next().done;
const any_ = (self) => !iterator_1(self).next().done;
exports.any_ = any_;

@@ -89,3 +91,3 @@ /**

*/
const associate = (self, transform) => {
const associate_1 = (self, transform) => {
const map = new Map();

@@ -96,3 +98,3 @@ for (const it of self)

};
exports.associate = associate;
exports.associate = associate_1;
/**

@@ -108,3 +110,3 @@ * Returns a [Map] containing the elements from the given collection indexed by the key

*/
const associateBy = (self, keySelector) => associate(self, (it) => [keySelector(it), it]);
const associateBy = (self, keySelector) => associate_1(self, (it) => [keySelector(it), it]);
exports.associateBy = associateBy;

@@ -120,3 +122,3 @@ /**

*/
const associateBy_ = (self, keySelector, valueTransform) => associate(self, (it) => [keySelector(it), valueTransform(it)]);
const associateBy_ = (self, keySelector, valueTransform) => associate_1(self, (it) => [keySelector(it), valueTransform(it)]);
exports.associateBy_ = associateBy_;

@@ -179,3 +181,3 @@ /**

const result = new Map();
return associateWithTo(self, result, valueSelector);
return associateWithTo_1(self, result, valueSelector);
};

@@ -191,3 +193,3 @@ exports.associateWith = associateWith;

*/
const associateWithTo = (self, destination, valueSelector) => {
const associateWithTo_1 = (self, destination, valueSelector) => {
for (const it of self)

@@ -197,3 +199,3 @@ destination.set(it, valueSelector(it));

};
exports.associateWithTo = associateWithTo;
exports.associateWithTo = associateWithTo_1;
/**

@@ -220,3 +222,3 @@ * Returns an average value of elements in the collection.

*/
exports.map = createIterable(function* (self, transform) {
exports.map = createIterable_1(function* (self, transform) {
for (const it of self)

@@ -235,4 +237,4 @@ yield transform(it);

*/
const iterator = (self) => self[Symbol.iterator]();
exports.iterator = iterator;
const iterator_1 = (self) => self[Symbol.iterator]();
exports.iterator = iterator_1;
/**

@@ -244,3 +246,3 @@ * Returns `true` if [element] is found in the collection.

*/
const contains = (self, element) => indexOf(self, element) !== -1;
const contains = (self, element) => indexOf_1(self, element) !== -1;
exports.contains = contains;

@@ -252,3 +254,3 @@ /**

*/
const elementAt = (self, index) => find(zip(self, exports.naturals), ([, i]) => i === index)?.[0] ?? (0, utils_js_1.throws)(new Exceptions_js_1.IndexOutOfBoundsException());
const elementAt = (self, index) => find_1(zip_1(self, naturals_1), ([, i]) => i === index)?.[0] ?? (0, utils_js_1.throws)(new Exceptions_js_1.IndexOutOfBoundsException());
exports.elementAt = elementAt;

@@ -259,3 +261,3 @@ /**

*/
function find(self, predicate) {
function find_1(self, predicate) {
for (const it of self)

@@ -265,3 +267,2 @@ if (predicate(it))

}
exports.find = find;
/**

@@ -272,4 +273,4 @@ * Returns first index of [element], or -1 if the collection does not contain element.

*/
const indexOf = (self, element) => find(zip(self, exports.naturals), ([it]) => it === element)?.[1] ?? -1;
exports.indexOf = indexOf;
const indexOf_1 = (self, element) => find_1(zip_1(self, naturals_1), ([it]) => it === element)?.[1] ?? -1;
exports.indexOf = indexOf_1;
/**

@@ -280,3 +281,3 @@ * Returns first element.

function first(self) {
const next = iterator(self).next();
const next = iterator_1(self).next();
if (!next.done)

@@ -290,3 +291,3 @@ return next.value;

function isEmpty(self) {
return iterator(self).next().done ?? false;
return iterator_1(self).next().done ?? false;
}

@@ -298,3 +299,3 @@ exports.isEmpty = isEmpty;

*/
const indexOf_ = (self, predicate) => find(zip(self, exports.naturals), ([it]) => predicate(it))?.[1] ?? -1;
const indexOf_ = (self, predicate) => find_1(zip_1(self, naturals_1), ([it]) => predicate(it))?.[1] ?? -1;
exports.indexOf_ = indexOf_;

@@ -304,5 +305,5 @@ /**

*/
exports.zip = createIterable((self, other) => {
const iter = iterator(self);
const otherIter = iterator(other);
const zip_1 = createIterable_1((self, other) => {
const iter = iterator_1(self);
const otherIter = iterator_1(other);
return {

@@ -318,2 +319,3 @@ next() {

});
exports.zip = zip_1;
/**

@@ -325,4 +327,4 @@ * Returns a lazy [Iterable] that wraps each element of the original collection

*/
const withIndex = (self) => (0, exports.zip)(self, exports.naturals);
const withIndex = (self) => zip_1(self, naturals_1);
exports.withIndex = withIndex;
//# sourceMappingURL=Iterable.js.map

@@ -6,4 +6,3 @@ "use strict";

const tsplus_module_3 = require("./Map");
const tsplus_module_4 = require("./Array");
const tsplus_module_5 = require("./Number");
const tsplus_module_4 = require("./Number");
const Iterable_js_1 = require("./Iterable.js");

@@ -138,8 +137,8 @@ describe("Iterable", () => {

test("average", () => {
expect(tsplus_module_4.average([])).toBeNaN();
expect(tsplus_module_4.average([1, 2, 5, 8, 3])).toBe(3.8);
expect(tsplus_module_1.average([])).toBeNaN();
expect(tsplus_module_1.average([1, 2, 5, 8, 3])).toBe(3.8);
expect(tsplus_module_1.average(tsplus_module_1.iterableOf(1.6, 2.6, 3.6, 0.6))).toBe(2.1);
expect(tsplus_module_1.average(tsplus_module_1.iterableOf(1.6, 2.6, 3.6, 0.6))).toBe(2.1);
const n = 100;
const range = tsplus_module_5.rangeTo((0), n);
const range = tsplus_module_4.rangeTo((0), n);
expect(tsplus_module_1.average(range)).toBe(n / 2);

@@ -146,0 +145,0 @@ });

/**
* @tsplus fluent Array sum
*/
export const sum = (self) => self.reduce((prev, cur) => prev + cur, 0);
const sum_1 = (self) => self.reduce((prev, cur) => prev + cur, 0);
export const sum = sum_1;
/**
* @tsplus fluent Array average
*/
export const average = (self) => sum(self) / self.length;
export const average = (self) => sum_1(self) / self.length;
/**

@@ -10,0 +11,0 @@ * @tsplus fluent Array distinct

import * as tsplus_module_1 from "./Array.js";
import * as tsplus_module_2 from "./Iterable.js";
describe("Array", () => {

@@ -8,3 +9,3 @@ const numbers = [1, 2, 3];

test("average", () => {
expect(tsplus_module_1.average(numbers)).toMatchInlineSnapshot(`2`);
expect(tsplus_module_2.average(numbers)).toMatchInlineSnapshot(`2`);
});

@@ -11,0 +12,0 @@ test("distinct", () => {

import * as tsplus_module_1 from "./Sequence.js";
export const createIterable = createIterable_1;
export const find = find_1;
// From: https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/common/src/generated/_Collections.kt

@@ -6,3 +8,3 @@ import { throws } from "../utils.js";

export const Iterable = {};
export function createIterable(iteratorFactory) {
function createIterable_1(iteratorFactory) {
if (iteratorFactory.length === 0)

@@ -16,3 +18,3 @@ return { [Symbol.iterator]: iteratorFactory };

export const iterableOf = (...elements) => ({
[Symbol.iterator]: () => iterator(elements),
[Symbol.iterator]: () => iterator_1(elements),
});

@@ -22,6 +24,7 @@ /**

*/
export const naturals = createIterable(() => {
const naturals_1 = createIterable_1(() => {
let n = 0;
return { next: () => ({ value: n++, done: false }) };
});
export const naturals = naturals_1;
/**

@@ -54,3 +57,3 @@ * Returns `true` if all elements match the given [predicate].

*/
export const any_ = (self) => !iterator(self).next().done;
export const any_ = (self) => !iterator_1(self).next().done;
/**

@@ -78,3 +81,3 @@ * Returns this collection as an [Iterable].

*/
export const associate = (self, transform) => {
const associate_1 = (self, transform) => {
const map = new Map();

@@ -85,2 +88,3 @@ for (const it of self)

};
export const associate = associate_1;
/**

@@ -96,3 +100,3 @@ * Returns a [Map] containing the elements from the given collection indexed by the key

*/
export const associateBy = (self, keySelector) => associate(self, (it) => [keySelector(it), it]);
export const associateBy = (self, keySelector) => associate_1(self, (it) => [keySelector(it), it]);
/**

@@ -107,3 +111,3 @@ * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given collection.

*/
export const associateBy_ = (self, keySelector, valueTransform) => associate(self, (it) => [keySelector(it), valueTransform(it)]);
export const associateBy_ = (self, keySelector, valueTransform) => associate_1(self, (it) => [keySelector(it), valueTransform(it)]);
/**

@@ -162,3 +166,3 @@ * Populates and returns the [destination] mutable map with key-value pairs,

const result = new Map();
return associateWithTo(self, result, valueSelector);
return associateWithTo_1(self, result, valueSelector);
};

@@ -173,3 +177,3 @@ /**

*/
export const associateWithTo = (self, destination, valueSelector) => {
const associateWithTo_1 = (self, destination, valueSelector) => {
for (const it of self)

@@ -179,2 +183,3 @@ destination.set(it, valueSelector(it));

};
export const associateWithTo = associateWithTo_1;
/**

@@ -200,3 +205,3 @@ * Returns an average value of elements in the collection.

*/
export const map = createIterable(function* (self, transform) {
export const map = createIterable_1(function* (self, transform) {
for (const it of self)

@@ -214,3 +219,4 @@ yield transform(it);

*/
export const iterator = (self) => self[Symbol.iterator]();
const iterator_1 = (self) => self[Symbol.iterator]();
export const iterator = iterator_1;
/**

@@ -222,3 +228,3 @@ * Returns `true` if [element] is found in the collection.

*/
export const contains = (self, element) => indexOf(self, element) !== -1;
export const contains = (self, element) => indexOf_1(self, element) !== -1;
/**

@@ -229,3 +235,3 @@ * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.

*/
export const elementAt = (self, index) => find(zip(self, naturals), ([, i]) => i === index)?.[0] ?? throws(new IndexOutOfBoundsException());
export const elementAt = (self, index) => find_1(zip_1(self, naturals_1), ([, i]) => i === index)?.[0] ?? throws(new IndexOutOfBoundsException());
/**

@@ -235,3 +241,3 @@ * Returns the first element matching the given [predicate], or `undefined` if element was not found.

*/
export function find(self, predicate) {
function find_1(self, predicate) {
for (const it of self)

@@ -246,3 +252,4 @@ if (predicate(it))

*/
export const indexOf = (self, element) => find(zip(self, naturals), ([it]) => it === element)?.[1] ?? -1;
const indexOf_1 = (self, element) => find_1(zip_1(self, naturals_1), ([it]) => it === element)?.[1] ?? -1;
export const indexOf = indexOf_1;
/**

@@ -253,3 +260,3 @@ * Returns first element.

export function first(self) {
const next = iterator(self).next();
const next = iterator_1(self).next();
if (!next.done)

@@ -262,3 +269,3 @@ return next.value;

export function isEmpty(self) {
return iterator(self).next().done ?? false;
return iterator_1(self).next().done ?? false;
}

@@ -269,9 +276,9 @@ /**

*/
export const indexOf_ = (self, predicate) => find(zip(self, naturals), ([it]) => predicate(it))?.[1] ?? -1;
export const indexOf_ = (self, predicate) => find_1(zip_1(self, naturals_1), ([it]) => predicate(it))?.[1] ?? -1;
/**
* @tsplus fluent Iterable zip
*/
export const zip = createIterable((self, other) => {
const iter = iterator(self);
const otherIter = iterator(other);
const zip_1 = createIterable_1((self, other) => {
const iter = iterator_1(self);
const otherIter = iterator_1(other);
return {

@@ -287,2 +294,3 @@ next() {

});
export const zip = zip_1;
/**

@@ -294,3 +302,3 @@ * Returns a lazy [Iterable] that wraps each element of the original collection

*/
export const withIndex = (self) => zip(self, naturals);
export const withIndex = (self) => zip_1(self, naturals_1);
//# sourceMappingURL=Iterable.js.map
import * as tsplus_module_1 from "./Iterable.js";
import * as tsplus_module_2 from "../util/Standard.js";
import * as tsplus_module_3 from "./Map.js";
import * as tsplus_module_4 from "./Array.js";
import * as tsplus_module_5 from "./Number.js";
import * as tsplus_module_4 from "./Number.js";
import { naturals } from "./Iterable.js";

@@ -135,8 +134,8 @@ describe("Iterable", () => {

test("average", () => {
expect(tsplus_module_4.average([])).toBeNaN();
expect(tsplus_module_4.average([1, 2, 5, 8, 3])).toBe(3.8);
expect(tsplus_module_1.average([])).toBeNaN();
expect(tsplus_module_1.average([1, 2, 5, 8, 3])).toBe(3.8);
expect(tsplus_module_1.average(tsplus_module_1.iterableOf(1.6, 2.6, 3.6, 0.6))).toBe(2.1);
expect(tsplus_module_1.average(tsplus_module_1.iterableOf(1.6, 2.6, 3.6, 0.6))).toBe(2.1);
const n = 100;
const range = tsplus_module_5.rangeTo((0), n);
const range = tsplus_module_4.rangeTo((0), n);
expect(tsplus_module_1.average(range)).toBe(n / 2);

@@ -143,0 +142,0 @@ });

{
"name": "@flock/kotlin-ts",
"version": "0.0.7",
"version": "0.0.8",
"author": "Kasper Peulen",

@@ -24,3 +24,3 @@ "license": "MIT",

"scripts": {
"release": "npm run build && cd build && npm publish",
"release": "npm t && npm run build && cd build && npm publish",
"build": "npm run build:clean && npm run build:esm && npm run build:cjs && cp package.json build/package.json && cp package.esm.json build/esm/package.json",

@@ -30,16 +30,8 @@ "build:cjs": "tsc -b tsconfig.cjs.json",

"build:clean": "rimraf build",
"preinstall": "update-ruecksichtslos --caret",
"postinstall": "tsplus-install",
"test": "jest",
"update": "npx --yes update-ruecksichtslos@latest --caret"
"test": "jest --all"
},
"devDependencies": {
"@effect-ts/build-utils": "^0.38.3",
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.7",
"@babel/plugin-transform-modules-commonjs": "^7.17.7",
"@changesets/changelog-github": "^0.4.3",
"@changesets/cli": "^2.21.1",
"@swc/cli": "^0.1.55",
"@swc/core": "^1.2.158",
"@tsplus/installer": "^0.0.37",
"@tsplus/installer": "^0.0.41",
"@types/jest": "^27.4.1",

@@ -51,3 +43,4 @@ "@types/node": "^17.0.21",

"ts-node": "^10.7.0",
"typescript": "^4.6.2"
"typescript": "^4.6.2",
"update-ruecksichtslos": "^0.0.17"
},

@@ -54,0 +47,0 @@ "prettier": {

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

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

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