New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

functionalscript

Package Overview
Dependencies
Maintainers
1
Versions
453
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

functionalscript - npm Package Compare versions

Comparing version 0.0.156 to 0.0.157

4

index.js

@@ -1,7 +0,3 @@

"use strict";
const lib = require('./lib')
const todo = () => lib.panic('not implemented')
/** @type {<F>(c: string, found: (before: string, after: string) => F, notFound: (c: string, source: string) => F) => (source: string) => F} */

@@ -8,0 +4,0 @@ const splitOne = (c, found, notFound) => source => {

24

iterable/test.js

@@ -6,8 +6,8 @@ const i = require('.')

const r = i.sum([120, 300, 42])
lib.panic_if('reduce')(r !== 462)
if (r !== 462) { throw 'error' }
}
{
lib.panic_if('first sum')(i.sum([1, 2]) !== 3)
lib.panic_if('second sum')(i.sum([1, 2]) !== 3)
if (i.sum([1, 2]) !== 3) { throw 'error' }
if (i.sum([1, 2]) !== 3) { throw 'error' }
}

@@ -17,16 +17,16 @@

const x = Array.from(i.map(a => a ** 2)([1, 2, 3]))
lib.panic_if('map')(x.length !== 3)
lib.panic_if('map[0]')(x[0] !== 1)
lib.panic_if('map[1]')(x[1] !== 4)
lib.panic_if('map[2]')(x[2] !== 9)
if (x.length !== 3) { throw 'error' }
if (x[0] !== 1) { throw 'error' }
if (x[1] !== 4) { throw 'error' }
if (x[2] !== 9) { throw 'error' }
}
{
lib.panic_if('join')(i.join('/')([]) !== '')
lib.panic_if('join')(i.join('/')(['a']) !== 'a')
lib.panic_if('join')(i.join('/')(['a', 'b']) !== 'a/b')
if (i.join('/')([]) !== '') { throw 'error' }
if (i.join('/')(['a']) !== 'a') { throw 'error' }
if (i.join('/')(['a', 'b']) !== 'a/b') { throw 'error'}
}
{
lib.panic_if('find')(i.find(x => x === 'c')(['a', 'b', 'c']) !== 'c')
if (i.find(x => x === 'c')(['a', 'b', 'c']) !== 'c') { throw 'error' }
}

@@ -42,3 +42,3 @@

([() => p, () => `${p}.js`, () => `${p}/index.js`])
lib.panic_if('map.find')(x('index.js') !== 'x')
if (x('index.js') !== 'x') { throw 'error' }
}

@@ -26,14 +26,2 @@ "use strict";

* @typedef {[T]|Continue<T>} Continuation
*/
/** @type {(_: string) => never} */
const panic = message => { throw message }
/**
* @template T
* @template R
* @typedef {{
* merge: (_: R) => (_: T) => R
* init: R
* }} Reduce
*/

@@ -81,19 +69,4 @@

panic,
todo: () => { throw 'not implemented' },
todo: () => panic('not implemented'),
/** @type {(_: string) => (_: boolean) => void} */
panic_if: message => condition => condition ? panic(message) : undefined,
/** @type {<T>(_: Continuation<T>) => T} */
trampoline: continuation => {
while (true) {
if (typeof continuation !== 'function') {
return continuation[0]
}
continuation = continuation()
}
},
pipe,

@@ -100,0 +73,0 @@

@@ -45,10 +45,9 @@ const { empty } = require('.')

const m = empty.set('x')(12).set('y')(44)
lib.panic_if('map.get(\'x\')')(m.get('x') !== 12)
lib.panic_if('map.get(\'y\')')(m.get('y') !== 44)
lib.panic_if('map.get(\'a\')')(m.get('a') !== undefined)
if (m.get('x') !== 12) { throw 'error' }
if (m.get('y') !== 44) { throw 'error' }
if (m.get('a') !== undefined) { throw 'error' }
const entries = Array.from(m.entries())
lib.panic_if('map.entries()')(entries.length !== 2)
if (entries.length !== 2) { throw 'error' }
}
{

@@ -55,0 +54,0 @@ /** @type {import('.').Map<number>} */

@@ -8,9 +8,12 @@ const i = require('.')

/** @type {<T>(_: T | undefined) => T} */
const cast = x => x === undefined ? lib.panic('x') : x
const cast = x => {
if (x === undefined) { throw 'x' }
return x
}
lib.panic_if('isRelative')(i.isRelative('a/b/c'.split('/')))
lib.panic_if('!isRelative')(!i.isRelative('./a/b/c'.split('/')))
lib.panic_if('pathNorm')(cast(i.pathNorm('a/../b'.split('/'))).join('/') !== 'b')
lib.panic_if('pathNorm')(cast(i.pathNorm('a/../b/../c'.split('/'))).join('/') !== 'c')
lib.panic_if('pathNorm')(cast(i.pathNorm('./a/../b/c/..//d/'.split('/'))).join('/') !== 'b/d')
if (i.isRelative('a/b/c'.split('/'))) { throw 'error '}
if (!i.isRelative('./a/b/c'.split('/'))) { throw 'error ' }
if (cast(i.pathNorm('a/../b'.split('/'))).join('/') !== 'b') { throw 'error ' }
if (cast(i.pathNorm('a/../b/../c'.split('/'))).join('/') !== 'c') { throw 'error ' }
if (cast(i.pathNorm('./a/../b/c/..//d/'.split('/'))).join('/') !== 'b/d') { throw 'error ' }

@@ -39,3 +42,4 @@ {

}
return ['.js', '', 'undefined.js'].includes(path) ? lib.panic('.js') : f[path]
if (['.js', '', 'undefined.js'].includes(path)) { throw '.js' }
return f[path]
},

@@ -64,3 +68,4 @@ id: ['c']

}
return ['.js', '', 'undefined.js'].includes(path) ? lib.panic('.js') : f[path]
if (['.js', '', 'undefined.js'].includes(path)) { throw '.js' }
return f[path]
},

@@ -78,4 +83,4 @@ id: ['']

const g = i.getModule({pack, local: []})
lib.panic_if('getModule')(g('') !== undefined)
lib.panic_if('getModule')(g('..') !== undefined)
if (g('') !== undefined) { throw 'error' }
if (g('..') !== undefined) { throw 'error' }
expect(g('.'))({ fileName: 'index.js', location: { pack, local: []}, source: './index.js'})

@@ -88,6 +93,6 @@ expect(g('./index'))({ fileName: 'index.js', location: { pack, local: []}, source: './index.js'})

expect(g('./a/index.js'))({ fileName: 'index.js.js', location: { pack, local: ['a']}, source: './a/index.js'})
lib.panic_if('getModule')(g('./x') !== undefined)
if (g('./x') !== undefined) { throw 'error' }
expect(g('a'))({ fileName: 'index.js', location: { pack: a, local: []}, source: 'a ./index.js'})
expect(g('a/index'))({ fileName: 'index.js', location: { pack: a, local: []}, source: 'a ./index.js'})
lib.panic_if('getModule')(g('b') !== undefined)
if (g('b') !== undefined) { throw 'error' }
expect(g('b/c'))({ fileName: 'index.js', location: { pack: c, local: []}, source: 'b/c ./index.js'})

@@ -101,3 +106,3 @@ expect(g('b/c/index'))({ fileName: 'index.js', location: { pack: c, local: []}, source: 'b/c ./index.js'})

const g = i.getModule({pack, local: ['index']})
lib.panic_if('getModule')(g('') !== undefined)
if (g('') !== undefined) { throw 'error' }
expect(g('..'))({ fileName: 'index.js', location: { pack, local: []}, source: './index.js'})

@@ -107,4 +112,4 @@ expect(g('.'))({ fileName: 'index.js', location: { pack, local: ['index']}, source: './index/index.js'})

expect(g('./index.js'))({ fileName: 'index.js', location: { pack, local: ['index']}, source: './index/index.js'})
lib.panic_if('getModule')(g('./index/') !== undefined)
lib.panic_if('getModule')(g('./a') !== undefined)
if (g('./index/') !== undefined) { throw 'error' }
if (g('./a') !== undefined) { throw 'error' }
expect(g('../a'))({ fileName: 'index.js', location: { pack, local: ['a']}, source: './a/index.js'})

@@ -114,6 +119,6 @@ expect(g('../a/index'))({ fileName: 'index.js', location: { pack, local: ['a']}, source: './a/index.js'})

expect(g('../a/index.js.js'))({ fileName: 'index.js.js', location: { pack, local: ['a']}, source: './a/index.js.js'})
lib.panic_if('getModule')(g('./x') !== undefined)
if (g('./x') !== undefined) { throw 'error' }
expect(g('a'))({ fileName: 'index.js', location: { pack: a, local: []}, source: 'a ./index.js'})
expect(g('a/index'))({ fileName: 'index.js', location: { pack: a, local: []}, source: 'a ./index.js'})
lib.panic_if('getModule')(g('b') !== undefined)
if (g('b') !== undefined) { throw 'error' }
expect(g('b/c'))({ fileName: 'index.js', location: { pack: c, local: []}, source: 'b/c ./index.js'})

@@ -120,0 +125,0 @@ expect(g('b/c/index'))({ fileName: 'index.js', location: { pack: c, local: []}, source: 'b/c ./index.js'})

{
"name": "functionalscript",
"version": "0.0.156",
"version": "0.0.157",
"description": "FunctionalScript is a functional subset of JavaScript",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,6 +9,6 @@ const lib = require('./lib')

/** @type {() => never} */
const assert = () => lib.panic('assert')
const assert = () => { throw 'assert' }
/** @type {(_: boolean) => void} */
const assert_if = c => lib.panic_if('assert_if')(c)
const assert_if = c => { if (c) { throw 'assert_if' } }

@@ -15,0 +15,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