npm.io
1.0.3 • Published 7 years ago

scpfn

Licence
MIT
Version
1.0.3
Deps
0
Size
24 kB
Vulns
0
Weekly
0
Stars
1

scpfn.js

Scope functions like Kotlin

Start

$ npm install scpfn

index.js:

const scpfn = require('scpfn').default;

scpfn.inject(Object.prototype);
console.log("test".let(it => it.toUpperCase())); // TEST
$ node index.js
TEST

Browser

  • Download dist/scpfn.min.js
  • index.html:
<script type="module">
import scpfn from './scpfn.min.js'
scpfn.inject(Object.prototype)

document.body.appendChild(document.createElement('span').also(it => {
    it.innerText = "Hello"
    let s = it.style
    s['color'] = 'white'
    s['background-color'] = 'darkgray'
}))
document.body.appendChild(document.createElement('span').also(it => {
    it.innerText = ", world!"
    let s = it.style
    s['color'] = 'black'
    s['background-color'] = 'lightgray'
}))
</script>

result base64

Keywords