npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

electron-localdata

v1.0.0

Published

An Electron data store that supports listening events

Downloads

1

Readme

electron-localdata

An Electron data store that supports listening events

Features

  1. Support the "main process" and "renderer process" sync read & write
  2. Supports event monitoring for "main process" and "renderer process"
  3. You can set the data key name as a localData instance of property name, easy to read and write
  4. No dependence

Installation

npm install --save  electron-localdata

API

  • LocalData(filepath, sync_write=true, keys)

    • filepath: The data store the file path, relative to the "userData"
    • sync_write: The default is true, when the data changes after synchronization storage, if set to false, need to manually call the save method
    • keys: Set the key name of the data as the attribute name of the LocalData instance
    const LocalData = require('electron-localdata')
    
    let localdata = new LocalData('test.json', true, ['abc'])

  • LocalData.create(filepath, sync_write=true, keys)

    This method is equivalent to new LocalData (), but if the data instance exists, it will return to the instance

  • LocalData.prototype.on(event_name, callback)

    localdata.on('changed', (event)=>{})
    // event = {type, key, newValue, oldValue} 
    
    localdata.on('deleted', (event)=>{})
    
    localdata.on('saved', (event)=>{})
    
    localdata.on('close', (event)=>{})

  • LocalData.prototype.get(key)

  • LocalData.prototype.set(key, value)

  • LocalData.prototype.keys()

  • LocalData.prototype.delete(key)

  • LocalData.prototype.save()

  • LocalData.prototype.close()

  • LocalData.prototype.property(keys)

    localdata.property(['abc', 'efg'])
    
    localdata.abc = 123
    
    console.log(localdata.abc)
    

支持监听事件的 Electron 数据存储库

特点

  1. 支持 “主程序“ 端 与 “渲染端“ 同时读写一份数据
  2. 支持 “主程序“ 端 与 “渲染端“ 的事件监听,任意一端发声改变,会同时接收到消息
  3. 可设置数据的键名作为 LocalData 实例的属性名,方便的读写数据的
  4. 无依赖

API

  • LocalData(filepath, sync_write=true, keys)

    • filepath: 数据存储的文件路径,相对于 userData 目录
    • sync_write: 默认为 true,当数据改变后同步存储,如果设置为 false,需手动调用 save 方法
    • keys: 设置数据的键名用作 LocalData 实例的属性名
    const LocalData = require('electron-localdata')
    
    let localdata = new LocalData('test.json', true, ['abc'])

  • LocalData.create(filepath, sync_write=true, keys)

    此方法等同 new LocalData(),但如果数据实例以存在的话,会返回以存在实例