Socket
Socket
Sign inDemoInstall

lazy-get-decorator

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.2 to 2.0.0

_bundle/fesm2015.js

87

package.json
{
"name": "lazy-get-decorator",
"version": "1.2.2",
"description": "Stub package for the soon-to-be-renamed \"typescript-lazy-get-decorator\"",
"main": "index.js",
"version": "2.0.0",
"description": "Lazily evaluates a getter on an object and caches the returned value",
"main": "LazyGetter.js",
"browser": "_bundle/umd.js",
"jsdelivr": "_bundle/umd.min.js",
"fesm5": "_bundle/fesm5.js",
"esm5": "_bundle/fesm5.js",
"fesm2015": "_bundle/fesm2015.js",
"esm2015": "_bundle/fesm5.js",
"es2015": "esm2015/LazyGetter.js",
"types": "LazyGetter.d.ts",
"module": "_bundle/fesm5.js",
"typings": "LazyGetter.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test:babel:legacy": "babel --config-file ./.babelrc.legacy -o test/LazyGetter.legacy.js test/LazyGetter.js",
"test:babel:new": "babel --config-file ./.babelrc.new -o test/LazyGetter.new.js test/LazyGetter.js",
"test:compile": "concurrently -n tsc:test \"tsc -p tsconfig.test.json\" \"npm:test:babel:*\"",
"test": "nyc mocha --check-leaks --exit --full-trace test/LazyGetter.legacy.js test/LazyGetter.new.js test/LazyGetter.typescript.js",
"pretest": "concurrently -n build:src,build:test,clean \"alo build --targets cjs\" \"npm run test:compile && ts-node pretest-postprocess.ts\" \"rimraf coverage\"",
"build": "alo build",
"lint": "alo tslint -p ./tsconfig.lib.json",
"lint:fix": "npm run lint -- --fix"
},
"author": "",
"license": "MIT"
"repository": {
"type": "git",
"url": "git+https://github.com/Alorel/typescript-lazy-get-decorator.git"
},
"keywords": [
"typescript",
"babel",
"lazy get",
"lazy getter",
"lazy",
"get",
"getter",
"cache",
"memoise",
"memoize",
"decorator"
],
"author": {
"name": "Arturas Molcanovas",
"url": "https://alorel.github.io",
"email": "a.molcanovas@gmail.com"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/Alorel/typescript-lazy-get-decorator/issues"
},
"homepage": "https://github.com/Alorel/typescript-lazy-get-decorator",
"devDependencies": {
"@alorel-personal/build-tools": "4.4.8",
"@alorel-personal/conventional-changelog-alorel": "2.0.4",
"@alorel-personal/semantic-release": "1.4.0",
"@alorel-personal/tslint-rules": "4.1.1",
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.4",
"@babel/plugin-proposal-class-properties": "~7.3.4",
"@babel/plugin-proposal-decorators": "~7.3.0",
"@semantic-release/changelog": "~3.0.0",
"@semantic-release/exec": "~3.3.2",
"@semantic-release/git": "~7.0.8",
"@semantic-release/github": "^5.2.10",
"@semantic-release/npm": "^5.0.2",
"@types/chai": "^4.1.7",
"@types/lodash": "~4.14.121",
"@types/mocha": "^5.2.6",
"@types/node": "~11.10.4",
"chai": "^4.2.0",
"concurrently": "~4.1.0",
"coveralls": "~3.0.3",
"cross-spawn": "~6.0.5",
"lodash": "~4.17.5",
"mocha": "^6.0.2",
"nyc": "~13.3.0",
"rimraf": "~2.6.3",
"semantic-release": "~15.13.3",
"source-map-support": "^0.5.10",
"ts-node": "^8.0.2",
"tslib": "~1.9.0",
"typescript": "^3.3.3"
},
"dependencies": {}
}

@@ -1,1 +0,89 @@

Stub package for the soon-to-be-renamed "typescript-proto-decorator"
# Lazy Get decorator
[![Build Status](https://travis-ci.org/Alorel/typescript-lazy-get-decorator.png?branch=2.0.0)](https://travis-ci.org/Alorel/typescript-lazy-get-decorator)
[![Coverage Status](https://coveralls.io/repos/github/Alorel/typescript-lazy-get-decorator/badge.svg?branch=2.0.0)](https://coveralls.io/github/Alorel/typescript-lazy-get-decorator?branch=2.0.0)
[![Greenkeeper badge](https://badges.greenkeeper.io/Alorel/typescript-lazy-get-decorator.svg)](https://greenkeeper.io/)
[![NPM](https://nodei.co/npm/lazy-get-decorator.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/lazy-get-decorator)
Previously known as [typescript-lazy-get-decorator](https://www.npmjs.com/package/lazy-get-decorator).
# Compatibility
- Typescript - full
- Spec-compliant decorator proposal - full
- Babel (current proposal) - full
- Babel (legacy) - full
# API
```typescript
/**
* Evaluate the getter function and cache the result
* @param {boolean} [setProto=false] Set the value on the class prototype as well. Only applies to non-static getters.
* @param {boolean} [makeNonConfigurable=false] Set to true to make the resolved property non-configurable
* @return {(target: any, key: string, descriptor: PropertyDescriptor) => void} A Typescript decorator function
*/
function LazyGetter(setProto: boolean = false, makeNonConfigurable = false) {}
```
# Usage
```typescript
import {LazyGetter} from 'lazy-get-decorator';
class AClass {
@LazyGetter()
get lazyNoProto(): string {
console.log('Evaluating lazyNoProto');
return 'lazyNoProtoValue';
}
@LazyGetter(true)
get lazyWithProto(): string {
console.log('Evaluating lazyWithProto');
return 'lazyWithProtoValue';
}
}
const inst1 = new AClass();
console.log('==== inst 1 ====\n');
console.log(inst1.lazyNoProto);
console.log(inst1.lazyNoProto);
console.log(inst1.lazyWithProto);
console.log(inst1.lazyWithProto);
const inst2 = new AClass();
console.log('\n\n==== inst 2 ====\n');
console.log(inst2.lazyNoProto);
console.log(inst2.lazyNoProto);
console.log(inst2.lazyWithProto);
console.log(inst2.lazyWithProto);
```
Output:
==== inst 1 ====
Evaluating lazyNoProto
lazyNoProtoValue
lazyNoProtoValue
Evaluating lazyWithProto
lazyWithProtoValue
lazyWithProtoValue
==== inst 2 ====
Evaluating lazyNoProto
lazyNoProtoValue
lazyNoProtoValue
lazyWithProtoValue
lazyWithProtoValue
index.js
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc