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 🙏

© 2026 – Pkg Stats / Ryan Hefner

device-data-module

v0.1.5

Published

Migrate data for device data

Readme

Device Data Module

npm version License: MIT

설명

device-data-module은 React Native 애플리케이션이 Android의 네이티브 SharedPreferences에 접근할 수 있도록 설계된 모듈입니다. 기존 네이티브 앱에서 사용하던 데이터를 Expo 모듈에서 읽거나 써야 할 때 유용하며, 점진적인 앱 마이그레이션 시 데이터 공유를 원활하게 해줍니다.

주요 기능은 네이티브 SharedPreferences 파일에 직접 접근하여 키-값 데이터를 저장, 조회, 삭제하는 것입니다.


설치

npm install device-data-module

또는

yarn add device-data-module

사용법

아래 예제는 device-data-module을 사용하여 데이터를 저장, 조회, 삭제하는 방법을 보여줍니다.

import { useState } from 'react';
import DeviceDataModule from "device-data-module";
import { Button, SafeAreaView, ScrollView, Text, TextInput, View, StyleSheet } from "react-native";

export default function App() {
  const [key, setKey] = useState('');
  const [value, setValue] = useState('');
  const [storedValue, setStoredValue] = useState<string | null>(null);

  // 주어진 키로 값을 저장합니다.
  const handleSetItem = async () => {
    if (key && value) {
      await DeviceDataModule.setItem(key, value);
      alert(`${key} 저장 완료!`);
    }
  };

  // 주어진 키의 값을 가져옵니다.
  const handleGetItem = async () => {
    if (!key) return;
    const result = await DeviceDataModule.getItem(key);
    setStoredValue(result || '값이 존재하지 않습니다');
  };

  // 주어진 키의 항목을 삭제합니다.
  const handleRemoveItem = async () => {
    if (!key) return;
    await DeviceDataModule.removeItem(key);
    setStoredValue(null);
    alert(`${key} 삭제 완료!`);
  };

  return (
    <SafeAreaView style={styles.container}>
      <ScrollView>
        <Text style={styles.header}>Device Data Storage 예제</Text>
        
        <View style={styles.inputGroup}>
          <TextInput
            style={styles.input}
            placeholder="키 (Key)"
            value={key}
            onChangeText={setKey}
          />
          <TextInput
            style={styles.input}
            placeholder="값 (Value)"
            value={value}
            onChangeText={setValue}
          />
        </View>

        <View style={styles.buttonGroup}>
          <Button title="값 저장 (Set Item)" onPress={handleSetItem} />
          <Button title="값 조회 (Get Item)" onPress={handleGetItem} />
          <Button title="값 삭제 (Remove Item)" onPress={handleRemoveItem} />
        </View>

        {storedValue && (
          <View style={styles.resultContainer}>
            <Text>저장된 값:</Text>
            <Text>{storedValue}</Text>
          </View>
        )}
      </ScrollView>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, padding: 20 },
  header: { fontSize: 24, fontWeight: 'bold', marginBottom: 20 },
  inputGroup: { marginBottom: 20 },
  input: { borderWidth: 1, borderColor: '#ccc', padding: 10, marginBottom: 10 },
  buttonGroup: { gap: 10, marginBottom: 20 },
  resultContainer: { padding: 10, backgroundColor: '#eee' },
});

API

setItem(key: string, value: string): Promise<void>

지정된 키(key)에 문자열 값(value)을 저장합니다.

  • key: 저장할 데이터의 키입니다.
  • value: 저장할 데이터의 값입니다.

getItem(key: string): Promise<string | null>

지정된 키(key)에 해당하는 값을 가져옵니다. 값이 없으면 null을 반환합니다.

  • key: 가져올 데이터의 키입니다.

removeItem(key: string): Promise<void>

지정된 키(key)에 해당하는 값을 삭제합니다.

  • key: 삭제할 데이터의 키입니다.

라이선스

이 프로젝트는 MIT 라이선스를 따릅니다. 자세한 내용은 LICENSE 파일을 참고하세요.